473,322 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 1255
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

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

Similar topics

1
by: Peter Zentner | last post by:
Hi all, is there a chance to append the text of the new selected item to the text in the textbox portion of the control? Example: textbox: "hello " new selected item: "world" new textbox...
1
by: Paul Gobée | last post by:
What is the parent element of a button (IE6 on Win, transitional mode)? Is it the BODY, the browser default stylesheet, or something else? Contra "body is parent-element": - Buttons with no...
8
by: pocm | last post by:
Hi, What's the property/value I need to set in css for A to mimic the results of <a href="..." target="_new">...</a>? Cheers, Paulo Matos
7
by: fremenusul | last post by:
I know I have been asking LOTS of xml questions and I really apprecaite all the help. Here is my XML file <?xml version="1.0" encoding="utf-8" ?> <products> <!-- Repeat the structure below...
2
by: mid | last post by:
Hello! First please understand tha my xml knowledge is very very short. I'm new at xml world. I need to understand how do I map a given sqlColumn to a xml element or attribute. I was given...
2
by: Jiho Han | last post by:
This has been asked many times before but it seems there haven't been clear answers. I have an application root at http://localhost and subdirectories http://localhost/app1
8
by: WordVBAProgrammer | last post by:
I've been struggling with this for a few days now. It worked originally as plain VB-type strings, but for some reason ceased creating the FileNm. I changed the code to use StringBuilder, but...
1
Eclipse
by: Eclipse | last post by:
G'day all Can anyone explain the difference in the results to me as I don't understand why specifying the directory name in two different ways could give a different answer. In CODE 1 below i...
42
by: Armin | last post by:
Hi, just a dumb question. Let a = Why is the value of a.append(7) equal None and not ?? --Armin
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.