Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a node to a document???

Status
Not open for further replies.

VBBoB

Programmer
Oct 24, 2000
4
US
I know a little bit about XML and using the MSXML3.0 parser but this stumps me and i keep finding the need to do it.
say i have this xml document:
<?xml version=&quot;1.0&quot;?>
<Rootnode>
<Header1>
<Item1>
<Cd>ASWE</CD>
<Val>154</Val>
</Item1>
<Item2>
<Cd>REWE</CD>
<Val>124</Val>
</Item2>
</Header1>
</Rootnode>

and then i have this fragment:
<Header2>
<Item1>
<Amt>145</Amt>
<Val>15465</Val>
</Item1>
<Item2>
<Amt>13</Amt>
<Val>1284</Val>
</Item2>
</Header2>

How can i add the fragment to the document at the &quot;Header&quot; level?

Any help will be appreciated.
BoB
 
Load each of the fragraments into DOM documents

//use the selectSingleNode method to goto the correct position

var oNode = xmlDocMain.selectSingleNode(&quot;Rootnode&quot;);

//get xml to add
var oNode2 = xmlDocSub.selectSingleNode(&quot;Header2&quot;);

//Add them together
oNode.appendChild(oNode2);



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top