This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
All that means is that the XPath expression you chose doesn't select any nodes from the document. One would have to look at the document to see why not. And right now, you're the only one who can do that. We can't see it from here.
Paul Clapham wrote:All that means is that the XPath expression you chose doesn't select any nodes from the document. One would have to look at the document to see why not. And right now, you're the only one who can do that. We can't see it from here.
Sorry You are right Paul , i forget to post the web.xml file , here is the part that i wanna get from the xml file
Clearly your first error is that the XPath expression is looking for a "wep-app" element as the root, whereas the root of that document is a "web-app" element.
But you're going to come back and tell me that was just a typing error when you made the post, the actual code does say "web-app". Then your problem is that all of your document is in the default namespace, whereas an XPath expression specifying an element name with no prefix is looking for elements with no namespace.
You can fix that by creating a namespace context which assigns the prefix "x" to the namespace URI "http://java.sun.com/xml/ns/javaee", and assigning that namespace context to your XPath object. Then change the XPath expression to "/x:web-app/x:context-param/x:param-name".
If I was going to suggest changing the XML document, I would have suggested just getting rid of the default namespace declaration. But I didn't suggest changing the XML document at all, because for all I know changing it would break something. What gave you that idea?
Joined: Feb 06, 2008
Your xpath should be something like where i=1,2,...