Well, I gave that a shot and it was much faster.  I looked at the code, because I don't want to capitalize my xhtml, and it's just walking the tree.  I was thinking it'd be maintaining a hashtable or something.  Makes you wonder why jaxen's so much slower...  So, I'll probably just write my own walking function that looks for the lower case id.  Here's the code I looked at:
Thanks Edwin, --Evan

    public Element elementByID(String elementID) {
        for (int i = 0, size = nodeCount(); i < size; i++) {
            Node node = node(i);

            if (node instanceof Element) {
                Element element = (Element) node;
                String id = elementID(element);

                if ((id != null) && id.equals(elementID)) {
                    return element;
                } else {
                    element = element.elementByID(elementID);

                    if (element != null) {
                        return element;
                    }
                }
            }
        }

        return null;
    }

    protected String elementID(Element element) {
        // XXX: there will be other ways of finding the ID
        // XXX: should probably have an IDResolver or something
        return element.attributeValue("ID");
    }

Edwin Dankert wrote:
I'm curious as to why the dom4j function elementByID does
not work.  It seems like this should be independent of Jaxen.
    

Actually, you are totally right ... I just had a look at the
implementation and it should indeed work ... the
elementByID method does not try to find elements with
attributes which have been specified as having the ID type but
attributes with a name of "ID". (make sure to use capitals)

Regards,
Edwin
  

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to