[XML-SIG] Does anyone do DOM navigation anymore?
bkline at rksystems.com
Tue Jul 6 13:30:59 CEST 2004
On Tue, 6 Jul 2004, Derek Fountain wrote:
> 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
> 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?
We use XSL/T to boil down the source document to the pieces we're
looking for into a predictable structure, then go after it with the DOM
mailto:bkline at rksystems.com
More information about the XML-SIG