Hi people!
i need to generate an xml using c#.net.how am i supposed to do,give me an example.
As i am a new comer for.Net.Try to explain me with crisp and clear.
Hope i get a best possible solution.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
muraliPosted Jun 20, 2008, 2:09 AM
i have generated an xml but fully hard code.Like
start element many child's and for that child i have sub-childs and end element.
so coding goes on and on.
Initially i want to take the worksheet names from an excel and column names and values from the excel.i have mentioned all the columns for getting the column names.I guess this is hard code.how can i simplify this.I guess you all understood.
thanks to all the friends in advance.
Bechir BejaouiPosted Jun 17, 2008, 10:35 AM
XmlDataDocument myDoc = new XmlDataDocument();
XmlElement E1 = myDoc.CreateElement("Element1");
XmlAttribute att1 = myDoc.CreateAttribute("attribute1");
XmlAttribute att2 = myDoc.CreateAttribute("attribute2");
att1.value = "value1";
att2.value = "value2";
E1.attributes.append(att1);
E1.attributes.append(att2);
myDoc.appendchild(E1);
myDoc.save(@"C:\myFile.xml");
excute the code and brwose to the path C:\myFile.xml and see what happens
This technology is called DOM document object model
Posted Jun 17, 2008, 9:25 AM
Friend this link vl give all basics about XML and also Xslt
www.topxml.com
http://weblogs.asp.net/sonukapoor/articles/133356.aspx
Niradhip ChakrabortyPosted Jun 17, 2008, 8:29 AM
You can refer the following articles for code in c# to generate xml.
http://www.codeproject.com/KB/XML/csharpcodedocumentation.aspx
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=773
But the best way to learn is go for some books on xml.
muraliPosted Jun 17, 2008, 5:22 AM
Nick NicholsPosted Jun 17, 2008, 4:58 AM
Niradhip ChakrabortyPosted Jun 17, 2008, 2:51 AM
Check Out the following article by Mahesh:
http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx
You also can refer following article:
http://www.devsource.com/c/a/Languages/Loading-Parsing-and-Generating-XML-using-C-and-the-SystemXML-Namespace/