Hi, I use IndexedDocumentFactory to create a document that supports indexed Element implementations to allow quicker lookup via name of Element and Attributes, as follows.
DOMReader reader = new DOMReader(); Dom4jXPath xpath = new Dom4jXPath(queryString); //queryString is an XPath expression. IndexedDocumentFactory fac = new IndexedDocumentFactory(); org.dom4j.Document dom4j = reader.read(doc); // doc is a w3c dom document. org.dom4j.Document indexed = fac.createDocument(); org.dom4j.Element e = dom4j.getRootElement(); e.detach(); indexed.add(e); List result = (List)xpath.evaluate(indexed); I do not observe any performance improvement compared with that not using IndexedDocumentFactory. But I do observe that jaxen/dom4j is significantly faster than jaxen/dom. Is the indexing enabled in dom4j by default? Thanks, Weijian On 21/03/06, Weijian Fang <[EMAIL PROTECTED]> wrote: > Hi, > > I am new to dom4j. Now I am using Jaxen/Dom4j to do Xpath query. I was > told that Dom4j supports indexing of dom elements to help XPath > queries. I find IndexedDocumentFactory and IndexedElement classes in > Dom4j API. Are they intended for such kind of indexing? > > Can you point me to any document or sample code of enabling elements > indexing in dom4j to help xpath query? > > Thanks a lot, > > Weijian > ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user