DOM XML

I'm cycling through an DOM Object and removing nodes. My problem is if I
want to remove nodes 1 and 3, it wants to remove nodes 1 and 4, because
once node 1 is removed, node 4 is now in the 3 slot.

Any direction or suggestions?

§
Sam [ Mo, 10 September 2007 06:17 ] [ ID #1816681 ]

Re: DOM XML

sam wrote:
> I'm cycling through an DOM Object and removing nodes. My problem is if I
> want to remove nodes 1 and 3, it wants to remove nodes 1 and 4, because
> once node 1 is removed, node 4 is now in the 3 slot.
>
> Any direction or suggestions?
>
> §

Yep, keep trace of what you want to remove and move the others up, start
from the back end and remove them moving up, or rescan after every removal.

As a general rule, *any* time you change data (not just a DOM object)
the data may be reordered. Never depend on the order remaining the same
after modifying the data - that includes adding and changing data, also
(although those probably wouldn't have an effect in this case).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex [at] attglobal.net
==================
Jerry Stuckle [ Mo, 10 September 2007 13:55 ] [ ID #1816687 ]
PHP » alt.php » DOM XML

Vorheriges Thema: Calendar and date functions
Nächstes Thema: Zend Debugger