Hi,

I've been trying to figure out how to work with XML in jQuery for the most
part of today as here is what I wanted to accomplish: 
1) read in an xml file and convert it to a workable object
2) modify the xml (do adds, removes, and changes to the xml object)
3) convert the xml object back to a string and export it

I've managed to do 1 and 3 (with the help of serializeXML), but I cannot
seem to do number 2 (add elements into the xml). I can traverse the xml
object and pull data out. For example:

XML
<?xml version='1.0' encoding='utf-8'?>
<pages>
  <page name="Page Name" id="p00001">something</page>
  <page name="SomeName" id="p00001">something</page>
</pages>

Code
alert($(jData).find("pages").children().attr("id")); //prints out "p00001"
fine

$(jData).find("pages").children().insertAfter('<page name="Page Name"
id="p00001">something</page>'); // does not add elements into the xml, but
clears the xml file

I've tried append(), before(), insertAfter() and they all do not work. My
problem is that I want to add nodes, remove nodes, change node values and
attributes, and I just can't seem to do it. Any help would be appreciated.

Thanks,
Jakub




-- 
View this message in context: 
http://www.nabble.com/Modiyfing-an-XML-document-with-jQuery-tp17308322s27240p17308322.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to