For this extremely simple search:


If you're starting from a SAX stream, the XPath solution is probably the better one.


If you're starting from a DOM tree: In general, simpler and less flexible tools tend to be faster, and tools built directly into a data model (such at the DOM) tend to be faster when operating on that model than external tools (such as an XPath processor). That's particularly true right now, since Xalan performance tuning has been focusing primarily on SAX-based processing than DOM-based (revisiting that is one of our pending work items).

Actually, these days DOM searching should be done using getElementsByTagNamesNS() (which is namespace-aware) rather than getElementsByTagName(). That's also more similar to the XPath's behavior.

Another alternative, as an intermediate point in this spectrum: If your DOM supports it, take a look at the DOM Level 2 Traversal chapter, which is more configurable/flexible than getElementsByWhatever but still may benefit from being built directly into the DOM.


______________________________________
Joe Kesselman / IBM Research

Reply via email to