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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append XML in ASP

Status
Not open for further replies.

ecannizzo

Programmer
Sep 19, 2000
213
US
I need to append a node to an xml document, but I have to first find the node to append to. In other words,

<question>
<ques text=&quot;what is...?&quot; id=&quot;1&quot;/>
<ques text=&quot;how many...?&quot; id=&quot;2&quot;/>
</question>

I need to find the ques with id = 2 and then append a child node underneath it named <answer>

Can someone help?

Thanks!
Erica
 
What you can do is open the document up in a DOM. You can then use the selectSingleNode method to get it. You can then add a child to that returned node:

Code:
strXPath = &quot;//ques[@id = 2]&quot;
set objElement = xmlDOM.documentElement.selectSingleNode(strXPath)
objElement.addChild ...

Not so sure about the add child bit but it will be defined in the SDK.

James :) James Culshaw
james@miniaturereview.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top