Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - How do I insert a node into a xml document? >Thread Next - Re: How do I insert a node into a xml document? Re: How do I insert a node into a xml document?To: NULL Date: 11/2/2004 2:56:00 PM I'm using MS XML 4.0, I'm not using VB (but it's very similar) so no
"Set" command is needed...
xmlDoc = ObjectOpen("Msxml2.DOMDocument.4.0")
xmlDoc.async = @False
xmlDoc.loadxml("<Book><Author>TJones</Author><Title>My
Book</Title></Book>")
DaNode = xmlDoc.selectSingleNode("//Book/Title") ;<-- choose the node
AFTER the Author...
newElement = xmlDoc.createElement("Subject")
; assign the new element a value...
newElement.text = "The Subject"
; append it to the document...
xmlDoc.documentElement.insertBefore(newElement, DaNode)
message("Debug", xmlDoc.xml)
exit
If <Book> isn't your root you can adjust the Xpath to locate it and
also the
line with .documentElement.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
