469,344 Members | 5,568 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Append xml1 as element in xml2 at specified path

Hi i have 2 xmls
xml1=
<ABRQ>
<HDR></HDR>
<REQUEST>
</REQUEST>
</ABRQ>

XML2=
<CONTRACT>
<ID/>
<NUMBER/>
<OWNER/>
</CONTRACT>

i want xml2 to be an element in xml1 . the result should be

<ABRQ>
<HDR></HDR>
<REQUEST>
<CONTRACT>
<ID/>
<NUMBER/>
<OWNER/>
</CONTRACT>
</REQUEST>
</ABRQ>
please use VBSCRIPT commands as the QTP testing tool uses vbscript only.
Mar 7 '07 #1
2 1180
dorinbogdan
839 Expert 512MB
I wrote a sample using vbscript, just to ilustrate the XMLDOM usage.
Save the code in a file as .htm and run it in IE:
[html]
<html>
<head>
<script type="text/vbscript">
sub vbtest()
dim xml1, xml2, req, el
Set xml1 = CreateObject("Microsoft.XMLDOM")
Set xml2 = CreateObject("Microsoft.XMLDOM")
xml1.loadXML document.getElementById("area1").value
xml2.loadXML document.getElementById("area2").value
set req = xml1.selectSingleNode("/ABRQ/REQUEST")
set el = xml1.createElement("CONTRACT")
req.appendChild xml2.selectSingleNode("/CONTRACT")
document.getElementById("area").value = xml1.xml
end sub
</script>
</head>
<body>
<textarea id="area1" rows = "10" cols ="30">
<ABRQ>
<HDR></HDR>
<REQUEST>
</REQUEST>
</ABRQ>
</textarea>
<textarea id="area2" rows = "10" cols ="30">
<CONTRACT>
<ID/>
<NUMBER/>
<OWNER/>
</CONTRACT>
</textarea>
<br>
<br>
<input type="button" value="Get XML result" onclick="vbtest()">
<br>
<br>

<textarea id="area" rows = "10" cols ="50"></textarea>

</body>
</html>
[/html]
Mar 7 '07 #2
dorinbogdan
839 Expert 512MB
Hi,
Did you succeed to solve the problem ?
If yes, please let me know, in order to close the thread.
Thanks,
Dorin.
Mar 21 '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 Peter Zentner | last post: by
7 posts views Thread by fremenusul | last post: by
2 posts views Thread by Jiho Han | last post: by
8 posts views Thread by WordVBAProgrammer | last post: by
42 posts views Thread by Armin | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.