| | |
appending xml document in C#
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2008
Posts: 13
Reputation:
Solved Threads: 0
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...
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
- Script to delete or backup logs at a specific time and under specific user (Shell Scripting)
- xml appending (C#)
- Append in xml document (C#)
Other Threads in the C# Forum
- Previous Thread: Flex ??
- Next Thread: fonction on any control
Views: 2231 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button c# chat check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption event excel file files form format forms ftp function gcd gdi+ http httpwebrequest image index input install java label list listbox listener login math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource saving serialization server sleep socket sql statistics stream string tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





