943,733 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 3146
  • C# RSS
Apr 18th, 2008
0

appending xml document in C#

Expand Post »
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...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kanjali is offline Offline
13 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Flex ??
Next Thread in C# Forum Timeline: fonction on any control





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC