473,687 Members | 3,770 Online
Bytes | Software Development & Data Engineering Community
+ 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:


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 3572
2 New Member
Hello again,

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

dataNode.getEle mentsByTagName( "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.

Aug 16 '07 #2
2,057 Recognized Expert Top Contributor
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

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

Similar topics

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 (PCDATA). All of HTML 4, xhtml – transitional, and xhtml-strict allow <div> to contain “unblocked” text. Does anybody know why – I’m looking for the philosophy behind allowing such. I’m in the process of encapsulating xhtml mark-up in content...
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 number of actual elements! This is because after every element node there is text node which is (I think) the whitespace in the XML document.
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 get *9*. In the example table, there are 4 rows with 4 columns each in the tbody. I'd expect 4 child nodes for the table body with 4 children each. I get those 4 plus 5 alerts in Mozilla/Netscape. I get only those 4 in IE and Opera. Note that...
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 a statement as follows: nodes = doc.SelectNodes(\\Node1\\Node\\DesiredNode); It gives me back in the collection all the DesiredNode tags. If I select retrieve the nth node as follows node = nodes;
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 = objconsultas.traerpartidosxfasexdeportedatareader(idfase, iddeporte)
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 concatenating them at the bottom and then concatenating them side by side: for ind in range(num_arrays): if ind == 0: bias_down1 = array(bias)
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 parent node has 100 nodes, I want to delete nodes 10 through 75, and not nodes 5, 10, 25 etc. I have a reference to the first and the last node in the list that has to be removed. Also it's position in the list, if that helps.
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 drag-and-drop functionality. Let's say I have the following: Sequence 1 - 1 - 2
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 able to produce a query that gives me two fields, Part_Number and Product_Type. Below you can see some sample data: Part_Number Product_Type 10MC35231 XYZ1A
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.