[XML-SIG] Filtering nodes from a DOM tree
Mon, 07 Jan 2002 23:13:04 -0500
The RELAX NG simplifications include a number of steps where certain
elements and attributes need to be dropped or modified. As a first
cut I'm just building a DOM tree and modifying, and there doesn't seem
to be any very neat way to do that.
There are NodeIterator and TreeWalker classes in xml.dom, but looking
at the code they don't seem to cope with the tree being modified while
it's being traversed. Is there an elegant way to do this kind of
filtering, in DOM or some other API?
I thought of writing XPath declarations for matching elements, and
then deleting or changing all the nodes that result, but that seems
likely to be slow because there are about 20 different simplifications
to be applied, and that would mean walking the whole document 20
A.M. Kuchling http://www.amk.ca
America doesn't have a monopoly on bad taste.
-- The Doctor, in "Revelation of the Daleks"