This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Strange behaviour with CachedXPathAPI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Strange behaviour with CachedXPathAPI" Watch "Strange behaviour with CachedXPathAPI" New topic

Strange behaviour with CachedXPathAPI

Jag Bains
Ranch Hand

Joined: Nov 19, 2002
Posts: 39
I have a strange problem when using CachedXPathAPI.selectNodeList(node, nodeName);
If the nodename is replace with a string literal e.g

or with a variable name that uses a literal e.g

Then the nodelist is retured perfectly fine.
However, if the nodeName comes from a hashMap e.g.

then I get the following exception:

Has anyone got any ideas why this is happening or how I can get around it?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Jag,
If you add a debug statement showing the value of your string (coming from the hashmap), you may discover that the problem is not with the XPathAPI but rather with the value you assign to the "NODENAME" key.
Jag Bains
Ranch Hand

Joined: Nov 19, 2002
Posts: 39
yes you are right. The value in my hashmap actually had " a round the text.
Stupid me.
It is sorta covered in the JavaRanch Style Guide.
subject: Strange behaviour with CachedXPathAPI
Similar Threads
Jtree adding nodes
Suppress text nodes in output when empty
XML dealing with the NamedNodeMap interface
xml JAVA
reading xml document by parsing