473,465 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Concatenate XML Nodes using Javascript

2 New Member
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:

[HTML]<person>
<data>
<value>1</value>
<value>2</value>
</data>
</person>[/HTML]

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");
  3.  
  4. var personNode = xmlDoc.getElementsByTagName("person").item(0);
  5. var dataNode = personNode.getElementsByTagName("data").item(0);
  6. valueNodes = dataNode.getElementsByTagName("value");
  7.  
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");
and
Expand|Select|Wrap|Line Numbers
  1. valueNodes = valueNodes & dataNode.getElementsByTagName("value");
but to no avail.

Any suggestions are appreciated :) Thanks!


Yenyen
Aug 16 '07 #1
2 3553
ysuwardy
2 New Member
Hello again,

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

dataNode.getElementsByTagName("value")

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.


Yenyen
Aug 16 '07 #2
jkmyoung
2,057 Recognized Expert Top Contributor
I don't know if something like this would improve performance.

http://tom-lee.blogspot.com/2006/06/...elists_08.html
joinNodeLists: function(list1,list2){
var i = list2.length - 1;

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

}
while(i--);

return list1;
}
Aug 17 '07 #3

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

Similar topics

1
by: Gordon - Adelphia | last post by:
I have a question regarding xhtml. Why, why, why does the ELEMENT <body> allow “unblocked” text. HTML does not (though, most browsers will render). Xhtml (transitional) however allows text nodes...
2
by: arvindsd | last post by:
Hi all, The code below gets me a list of all the nodes within the node object called xml_tags_root. NodeList nl = xml_tags_root.getChildNodes(); The length of nodelist I get is double the...
13
by: kaeli | last post by:
Can anyone explain this to me? It's driving me insane. Save this and run it in IE or Opera and then in Mozilla or Netscape 6+. In IE/Opera, I get the expected 4 alerts. In Mozilla/Netscape, I...
6
by: Paul J Lay | last post by:
I am using the XmlDocument Select Nodes method and it seems to work OK except that it returns embedded nodes in the collection when I only want the nodes that are not embedded. For example I have...
0
by: Luis Esteban Valencia | last post by:
Hello I am in big troubles trying to concatenate this I have a datalist Private Sub llenardatalistpartidos(ByVal idfase As Int32, ByVal iddeporte As Int32) Dim dr As sqldatareader dr =...
6
by: Sheldon | last post by:
Hi, I am trying to build a large array using concatenate function in python. So as I loop over the number of arrays, of which there are 12 (4 down and 3 across), I create 3 long arrays by...
1
by: Daniel Rucareanu | last post by:
Hello, Does anybody knows how can you delete, in just one step, not using a loop, a subset of the child nodes of a given DOM parent node? The subset will be continous, so for example, if the...
4
by: javascript | last post by:
I am wondering if it is possible to create a JavaScript function that will re-order child nodes in an Xml Document. Currently I am binding an Xml Data Island to an HTML table and implemented...
10
by: Aaron Hoffman | last post by:
Hello, I'm hoping someone might be able to offer some guidance to my problem. I have one query in MS Access which consists of 2 tables joined by a SEQUENCE_ID. By joining the two tables I am...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.