XPath evaluation

J

Josef Garvi

I'm trying to do some basic things with the new XPath class in JDK 1.5.

When evaluating the path "/", I thought I was going to get my document root
element (see http://www.w3schools.com/xpath/xpath_location.asp), but I get
the XML encoding header node instead:

"<?xml version="1.0" encoding="UTF-8"?>"

I'm just trying something simple like:

Node node =
(Node) xpath.evaluate("/", doc, XPathConstants.NODE);


Have I misunderstood the use of "/"?

--
Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty
 
J

Josef Garvi

Larry said:
Josef Garvi wrote:

According to this:
<http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/xslt/1_intro.html>

"The root element of the XML data is modeled by
an element node. The XPath root node contains the
document's root element, as well as other information
relating to the document."

Thanks. Studying that page showed I have to write "/*" rather than "/".

--
Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top