Adding XML comment to large number of existing XML Files?
I have several XML files, and i want to add an XML comment at the top of each file using C#.
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.
Roei BarPosted Sep 20, 2009, 8:09 AM
here is a sample code:
Tamer KhalilPosted Sep 19, 2009, 11:38 PM
XmlNode node = doc.CreateNode(XmlNodeType.Comment, "Comments", "");And this part is not has a problem
XmlNode dummy = doc.InsertBefore(doc.GetElementsByTagName("Main","")[0], node);Master BillaPosted Sep 19, 2009, 11:05 PM
You can do this code
protected void Button1_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load("");
XmlNode node = doc.CreateNode("Comments", "Comments", "");
node.InnerText = "This is sytem comments";
XmlNode dummy = doc.InsertBefore(doc.GetElementsByTagName("Main", "")[0], node);
doc.Save("filePath");
}
thank you