mona Posted March 30, 2006 Share Posted March 30, 2006 I'm trying to use the xml dom to edit the xml document, I found some functions that add new element, add new node text, update the elements values and attributes value, this is nice, but the problem is that how can I save them again in the xml file.you can see the example below,this example add a new element in the xml file (note.xml) but it display the file before and after:I need to save it after editing it, does anyone has an idea.also Is there a way to edit the file using php or xsl ?<html><head><script type="text/javascript">var xmlDocfunction loadXML(){if (window.ActiveXObject) { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("note.xml"); getmessage() }}function getmessage(){document.write("The original XML:");document.write("<xmp>" + xmlDoc.xml + "</xmp>");var newnode=xmlDoc.createElement("new element");xmlDoc.documentElement.appendChild(newnode);document.write("After appending the new node:");document.write("<xmp>" + xmlDoc.xml + "</xmp>");}</script></head><body onload="loadXML()"></body></html> Link to comment Share on other sites More sharing options...
dooberry Posted March 31, 2006 Share Posted March 31, 2006 this is actually covered in the tutorial, but there is a snag if you're using it on a client rather than a server.In your code all you need to do is add :xmldoc.save("<enter the path and filename here>") Dooberry Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now