logo       

Re: DOM : removeall nodes with xpath: msg#00031

mozilla.devel.dom

Subject: Re: DOM : removeall nodes with xpath



rvj wrote:

I think the problem you
run into is that you use nextSibling.nextSibling trying to move from
element to element node however after the removal of one <node
about="node:3" label="hello"/> element node there are two adjacent white
space text nodes between
<node about="node:2" />
and
<node about="node:4" />



I hadnt appreciated the significance of the interleaved
whitespace nodes

So does this mean I should ALSO be able to just remove the target's
associated white space node using
something like nextsibling.removeChild so preserving the interleaved
format.......

I wouldn't assume that nextSibling is any particular type of node, to be safe I would check its type e.g.
node.nextSibling.nodeType == 3
whether it is a text node and if needed also check its content whether it is all whitespace.

.. and can I always assume interleaved whitespace nodes are always created
during xmldoc.load() ?

With Mozilla yes, if there are white space text nodes between element nodes then Mozilla models them in the document tree. MSXML for instance is different, it has an option to switch that on/off.

--

Martin Honnen
http://JavaScript.FAQTs.com/


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise