0

how to add element to a xml file using asp.net& c#.net inweb application

2
  • It'd be helpful if you were a bit more specific about the element you want to add, perhaps giving us a sample of the file you want to modify? =) Commented Feb 17, 2010 at 10:00
  • Are you using Linq to XML or some thing ? Just asking .. Commented Feb 17, 2010 at 10:03

3 Answers 3

3

Here's an example of adding a new element to the root node:

XDocument doc = XDocument.Load("test.xml");
doc.Root.Add(new XElement("someNode", "some node value"));
doc.Save("test.xml");
Sign up to request clarification or add additional context in comments.

Comments

0

Load the document using XmlDocument class and then modify it as needed. Reference documentation and examples here.

Comments

0

You can use XmlDocument.CreateElement method to create it and then to append it

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.