Using jQuery to copy an XML node to another XML file?

I am trying to combine data from multiple xml sources into a single XML file using JavaScript or jQuery. I iterate over the files using jquery $ .Ajax to read the file and select the first node (node ​​I want) and want to copy and add it to my destination XML file and then go.

I can select the first row using:

firstRow = $(testThis.responseXML).find("z\\:row:eq(0)"); // get the first row
 alert('firstRow : ' + firstRow  );  // check the node text

But I can not copy node and add it. I am trying to use:

newXMLData.append($(firstRow).text()); // append row to new xml file

I tried using .text (),. HTML () ,. val (), but nothing works.

Any ideas?

+3
source share
2 answers

Have you tried just newXMLData.append (firstRow)?

Here you have a good example about managing jquery and xml:

http://www.bennadel.com/blog/1054-jQuery-Demo-Working-With-XML-Documents.htm

, :.find( "person [type = 'girl']" ), , , Xpath.

0

clone() node, , node 2 .

0

Source: https://habr.com/ru/post/1770358/


All Articles