appending xml document in C#

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 13
Reputation: kanjali is an unknown quantity at this point 
Solved Threads: 0
kanjali kanjali is offline Offline
Newbie Poster

appending xml document in C#

 
0
  #1
Apr 18th, 2008
HI,

I need to append new tags to the existing xml document.
PLease review this code ,

string txt = TextBox1.Text.ToString();
XmlDocument doc= new XmlDocument();
doc.LoadXml(txt);
XmlElement el = doc.CreateElement("property1");
el.SetAttribute("name1", "C1");
el.InnerText = "This row is being appended to the end of the document.";
doc.DocumentElement.AppendChild(el);
doc.Save(txt);

This code will be helpful to create the childnode, but iam looking for appending Root node as well as childnodes.
Please help me to extend this code for Root nodes.

Note : no need to create XmlDeclaration statement becoz it will be thr for selected xml file by default.

Appreciate your precious reply.

Thanks a lot,
Anjali...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC