Discussion Locked

Updating the XML file permanantly

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

Using the createElement XML DOM method you can add elements and text to an XML file in memory but does anyone know any ways of performing this permanantly.

For example, I'd like to make a form where I click on submit and it adds elements to an XML file. When I then open the XML file I should be able to see the element I've just added...

Thanks.
James

1 reply

by mark

James,

You should be able to use the save method. In other words, you create an XML object in memory, load your file into it, create your element and assign text to it, append the element to your XML object and save it.

For example in asp it may look something like:

set objXML = Server.CreateObject("MSXML2.DOMDocument")

objXML.load [james xml file]

set objNewElement = objXML.createElement("newelement")

objNewElement.text = "your text here"

set objRoot = objXML.selectSingleNode("[root element]")

objRoot.appendChild objNewElement

objXML.save [james xml file]

Hope that helps.

Mark

This discussion is closed to new replies.