View Single Post
Old December 18th, 2003, 05:31 AM
pgtips pgtips is offline
Friend of Wrox
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

The way you are doing things you cannot back out to the parent, because you have overwritten the original xml document with just the fragment you have created.

You don't need to do things like this:
xmlDoc.loadXML _
    Set ObjElement = xmlDoc.documentElement

what you can do instead is just
Set ObjElement = ObjElement.childNodes.item(x)
then you still have the element you want in ObjElement *and* you still have the whole xml document in xmlDoc.

Also, make sure your CreateXML function is using the original xmlDoc and its createElement() or createNode() methods to create the child node.

Finally, I think you would benefit from learning XPath and the selectNodes() or selectSingleNode() methods. Its much more efficient than looping through all child nodes to find a certain node. For example you could do
Set ObjElement = xmlDoc.selectSingleNode("/RadialDetails[@id='" & RadID & "']/Observations")
to go straight to the element you want (I'm guessing the exact path here because you don't show us what your xml looks like).