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

brett hartshorn bhartsho at yahoo.com
Tue Jul 6 08:08:19 CEST 2004

I use DOM for almost everything, its great but you have to extend it to do your searches in an
effective way.
See dotWith, this is my DOM extension. http://opart.org/dotWith/dotWith.py

--- "Thomas B. Passin" <tpassin at comcast.net> wrote:
> Derek Fountain 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 tend to use getElementsByTagName() and getElementById() as much as 
> possible.  These, along with parentNode, help you avoid - well, OK, 
> reduce - that kind of dependence on precise structural details.  Of 
> course, these are only useful if you know pretty well what you are 
> looking for.  If you do, they reduce the fussiness.
> In my own html/xhtml, I find that I also am helped by looking at the 
> values of class attributes.  I would find it helpful if there were a 
> specific call (in the html dom, anyway), thisNode.getElementsByClassName().
> > 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. 
> You especially want to avoid getting fooled by whitespace-only text 
> nodes and more generally, multiple PCData fragments.
> Cheers,
> Tom P
> -- 
> Thomas B. Passin
> Explorer's Guide to the Semantic Web (Manning Books)
> http://www.manning.com/catalog/view.php?book=passin
> _______________________________________________
> XML-SIG maillist  -  XML-SIG at python.org
> http://mail.python.org/mailman/listinfo/xml-sig

Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!

More information about the XML-SIG mailing list