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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

saving xml creation / update to file

Status
Not open for further replies.
Joined
Aug 1, 2005
Messages
25
Location
US
Hi

My xml shows as follows
in asp.net

Dim xml As New XmlDocument
xml.Load(Server.MapPath("xmlList.xml"))
Dim xNode As XmlNode
xNode = xml.SelectSingleNode("grub/pizza")
Dim xElem As XmlElement
xElem = xml.CreateElement("topping")
xElem.InnerText = "cheese "
xNode.AppendChild(xElem)

Label1.Text = xml.InnerXml

xNode.RemoveChild(xNode.ChildNodes(1))

Label2.Text = xml.InnerXml

Everything flows fine, but how can I update my xml file properly?

Many thanks!



 
You can solve a lot of problems by looking at relevant object documentation first. Here's the save method of the XmlDocument:

Code:
Dim writer as XmlTextWriter = new XmlTextWriter("data.xml",nothing)
writer.Formatting = Formatting.Indented
doc.Save(writer)

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top