Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > "node.InsertAfter" method only inserts node on final call

Reply
Thread Tools

"node.InsertAfter" method only inserts node on final call

 
 
chris yoker
Guest
Posts: n/a
 
      01-28-2005
hiya,

I succesfully return a "nodeList" thru the "xmlDoc.SelectNodes" method.
This nodeList is taken from a repetitive, uniform xml doc.

I can successfully append a child node at the correct position using the
following code:

<code>
<!--Node inserted into corrrect position in nodeList(0)-->
nodeList(0).InsertAfter(additionalNode, nodeList(0).ChildNodes(5))
</code>

however, as soon as I try to do the same with nodeList(1), then
apparently the SAME code that previously inserted the node into
nodeList(0) doesn't do its job.

<code>
<!--Node NOT inserted into nodeList(0)-->
nodeList(0).InsertAfter(additionalNode, nodeList(0).ChildNodes(5))

<!--Node inserted into corrrect position in nodeList(1)-->
nodeList(1).InsertAfter(additionalNode, nodeList(1).ChildNodes(5))
</code>


Surely, If i am using the "InsertAfter" method, then the node should
have been inserted BOTH times?

As a test, I swapped my code round, and I can confirm that the node is
ONLY inserted on the 2nd call.

<code>
<!--Node NOT inserted into nodeList(1)-->
nodeList(1).InsertAfter(additionalNode, nodeList(1).ChildNodes(5))

<!--Node inserted into corrrect position in nodeList(0)-->
nodeList(0).InsertAfter(additionalNode, nodeList(0).ChildNodes(5))
</code>

Can someone comment?I have been spent a bit of time on this, and am no
further forward.
Even if i could get hold of some sample code in vb / c# that did this,
then I'm sure I could take it from there

ta,
yogiberr

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      01-29-2005
/chris yoker/:

> <code>
> <!--Node NOT inserted into nodeList(0)-->
> nodeList(0).InsertAfter(additionalNode, nodeList(0).ChildNodes(5))
>
> <!--Node inserted into corrrect position in nodeList(1)-->
> nodeList(1).InsertAfter(additionalNode, nodeList(1).ChildNodes(5))
> </code>
>
>
> Surely, If i am using the "InsertAfter" method, then the node should
> have been inserted BOTH times?
>
> As a test, I swapped my code round, and I can confirm that the node is
> ONLY inserted on the 2nd call.
>
> <code>
> <!--Node NOT inserted into nodeList(1)-->
> nodeList(1).InsertAfter(additionalNode, nodeList(1).ChildNodes(5))
>
> <!--Node inserted into corrrect position in nodeList(0)-->
> nodeList(0).InsertAfter(additionalNode, nodeList(0).ChildNodes(5))
> </code>


Surely it is inserted both times but it is getting removed prior
inserting it the second time. There's no 'InsertArfter' method in
the standard DOM interfaces but if you look at the
'Node.appendChild' [1], 'Node.insertBefore' [2] and
'Node.replaceChild' [3] documentation you would find:

> If the 'newChild' is already in the tree, it is first removed.


[1] http://www.w3.org/TR/DOM-Level-2-Cor...ml#ID-184E7107
[2] http://www.w3.org/TR/DOM-Level-2-Cor...l#ID-952280727
[3] http://www.w3.org/TR/DOM-Level-2-Cor...l#ID-785887307

--
Stanimir
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to delete last node of a Linked list if you only know the address of last node. sangram C Programming 16 12-01-2006 08:57 PM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
FormView for inserts only =?Utf-8?B?ZG1hbm5pb24=?= ASP .Net 0 04-18-2006 08:21 PM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
Can I implement INSERTs and DELETEs in DAOs or only in EntityBeans? Tobias Merler Java 6 09-30-2004 02:37 PM



Advertisments