Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a new XmlNode to a file??? 1

Status
Not open for further replies.

juhaka

Programmer
Nov 14, 2002
26
FI
Hi!
How can I add a new node to a existing xml -file? XmlNode -class has a method, AppendChild(XmlNode node), but I can't create a new node (XmlNode newNode = new XmlNode()), because XmlNode is a abstract class. But there must be some way to create a new node...? How could I do it? Please, tell me!
br. Juha Ka
 
Try this:
Code:
XmlNode newElem = doc.CreateNode(XmlNodeType.Element, "NodeName", "");
You can also create an element like this:
Code:
XmlElement newElem = doc.CreateElement("NodeName");
Take a look at ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemXmlXmlDocumentClassCreateElementTopic.htm for more info.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top