Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XPATH vs DOM tests acomplishied

843834Jul 27 2001 — edited Jul 29 2001
hi, i performed some test trying to select one node in a document with 10000 nodes (<name first="ssss" last="sss">) and the test said:

[bold]Using xpath[bold]
String xpath = "/doc/name[@first=\"Rodrigo\"]";
Node node = XPathAPI.selectSingleNode(doc, xpath);
[bold]it delay like 1970 milliseconds[bold]


[bold]Using dom[bold]
NodeList nodeList = (NodeList)doc.getElementsByTagName("name");
    int length = nodeList.getLength();
    for (int i = 0; i < length; i++) {
      Element node = (Element)nodeList.item(i);
      String name = node.getAttribute("first");
      if (name.equals("Rodrigo")) {
        break;
      }
    }
[bold]it delay like 1010 milliseconds[bold]

HOW CAN IT BE ?????
xpath is more slower than dom ??????

thanks

Rodrigo Gonzalez Asensio
Researcher & Developer
Buenos Aires - Argentina


Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 26 2001
Added on Jul 27 2001
1 comment
108 views