Jump to content

Editing XML in Browser and save back to file


FeFe

Recommended Posts

Does someone knows a script or anything written in JavaScript for editing XML files in the browser (FF(2.0),IE(6.0))?I am not thinking fancy, but just simple Add new node/Copy whole node with nested childs/Save XML/Load XML.I want to allow my user to edit XML files in the company. It would be preferable to be able to edit after it rendered to the browser nicely with XSL. I mean when I open an xml file in the browser which has set the <?xml-stylesheet href="mystyle.xsl" type="text/xsl"?>The browser render it properly at least in IE and FF but intact the XML as if you view the page's source it is the XML.So I think if I could modify the XML and get the modifications saved back to the XML file than refresh, the modified XML should be shown again, assumed that the structure of the XML is stays valid.Is something like this exist out there? :)

Link to comment
Share on other sites

Javascript does not save files, and it doesn't display what you've modified in the XML. You'd do better learning XML DOM and then studying some PHP to get it to work.

Link to comment
Share on other sites

I see. OK, I can load the file from PHP and save it back as I do at the moment, but is there any already written script to add/Duplicate a whole node if it is no the root node? If there is I rather would use it than start write something already made and may also tested.

Link to comment
Share on other sites

You need to use DOM methods.In PHP to create a node would be something like this (supposing $xmldoc is a loaded XML document):

$newNode = $xmlDoc->createElement("something");$xmlDoc->documentElement->appendChild($newNode);

To copy a node you woud use the cloneNode() function.Study XML DOM and check all the XML DOM functions here: http://w3schools.com/dom/dom_node.asp

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...