[XML-SIG] Does anyone do DOM navigation anymore?

Derek Fountain derekfountain at yahoo.co.uk
Tue Jul 6 05:40:38 CEST 2004

On Monday 05 July 2004 23:34, you wrote:
> I use the DOM navigation all the time.
> I do not know about XPATH so I cannot say if I would use that more than
> DOM.

How do you cope with the fact that documents are to some extent unpredictable? 
Do you make heavy use of the methods/attributes which allow you to "feel 
around" to see what's coming (hasChildNodes, nodeType and so on)? Or do you 
only use DOM when you can be guaranteed about the structure of the document, 
and you therefore know that, for example, 
currentNode.firstChild.firstChild.lastChild.firstChild.nodeValue will give 
you text you're after?

I'm starting to wonder if I've been doing the DOM right, as it were. It seems 
to me that when you don't know in advance how many children an element has, 
and you have to start feeling your way around, it makes the code rather 
fragile. Someone adds an extra child where your test cases never had one, and 
boom, the code breaks. Perhaps people code to the DTD, rather than any one 
document itself?

More information about the XML-SIG mailing list