469,904 Members | 2,231 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

Concatenate XML Nodes using Javascript

Hello everyone,

I have a question on XML with Javascript. Here is my situation:

I have two xml documents (1.xml and 2.xml) with similar structure:


Using Javascript, I managed to load the 1.xml document, store the <value> nodes into a variable called valueNodes.

Expand|Select|Wrap|Line Numbers
  1. var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  2. xmlDoc.load("note.xml");
  4. var personNode = xmlDoc.getElementsByTagName("person").item(0);
  5. var dataNode = personNode.getElementsByTagName("data").item(0);
  6. valueNodes = dataNode.getElementsByTagName("value");
My question: when I load 2.xml, is there a method to get the <value> nodes and then concatenate them to nodes that I already have in valueNodes? I have tried

Expand|Select|Wrap|Line Numbers
  1. valueNodes = valueNodes + dataNode.getElementsByTagName("value");
Expand|Select|Wrap|Line Numbers
  1. valueNodes = valueNodes & dataNode.getElementsByTagName("value");
but to no avail.

Any suggestions are appreciated :) Thanks!

Aug 16 '07 #1
2 3169
Hello again,

To clarify my question, what I need is to concatenate the results of


to valueNodes, that is, all the nodes. Just found out there is appendChild function, to use this I will need to iterate the results and append one by one, but this will take to much resource for me as there are about 6000 nodes to append.

Thanks again for any suggestions.

Aug 16 '07 #2
2,057 Expert 2GB
I don't know if something like this would improve performance.

joinNodeLists: function(list1,list2){
var i = list2.length - 1;

do{ list1[list1.length] = list2[i];


return list1;
Aug 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Gordon - Adelphia | last post: by
2 posts views Thread by arvindsd | last post: by
6 posts views Thread by Paul J Lay | last post: by
reply views Thread by Luis Esteban Valencia | last post: by
6 posts views Thread by Sheldon | last post: by
4 posts views Thread by javascript | last post: by
10 posts views Thread by Aaron Hoffman | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.