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

Clone and InsertAfter Problem

Status
Not open for further replies.

MartinCopp

Programmer
Jan 7, 2008
2
CA
I'm having a problem with inserting a cloned node into a document object. This is in a VB.net application.

The jist of the code is.

Dim mainXML as XMLNode
Dim tempXML as XMLNode

tempXML = mainXML.CloneNode
mainXML.ParentNode.InsertAfter(WhereWeWantToInsert, tempXML)

If I don't clone the node, it moves the node from its previous location to the new locale.

I tried importing the node, no dice.

Any suggestions?
 
Are you getting an error message when you insert the cloned node?
 
[1] >tempXML = mainXML.CloneNode
[tt]tempXML = mainXML.CloneNode[red](true)[/red] 'or false if not deep clone is intended.[/tt]

[2] >mainXML.ParentNode.InsertAfter(WhereWeWantToInsert, tempXML)
[tt]mainXML.ParentNode.InsertAfter([red]tempXML,WhereWeWantToInsert)[/red][/tt]
It is also dependent on the correctness of WhereWeWantToInsert: whatever it is, it should be a child node of mainXML.ParentNode or nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top