I have a method (getSingleNodeValue()) which when passed an xpatch expression will extract the value of the specified element in the xml document refered to in 'doc'. Assume doc at this point has been initialised as shown below and xmlInput is the buffer containing the xml content.

The same method works with other xml documents so i am not sure what is special about this one. There is no exception so the xml is valid xml. Its just that the method always sets 'list' to null. Any ideas?

Edit

Ok as suggested, here is a simple running program that demonstrates the above

1 Answer
1

The problem is with XML namespaces: your XPath query starts by selecting a 'TOP4A' element in the default namespace. Your XML file, however, has a 'TOP4A' element in the 'http://www.testurl.co.uk/enment/gqr/3232/1' namespace instead.

No the xml document will be recieved in exactly the format i showed above and i cant modify it. Is there anyway i can tell it to ignore namespaces?
–
ziggySep 3 '11 at 16:08

I see you're stuck with jdk1.4/jdom so you can't use the standard javax.xml.parsers stuff - not sure about any other options. I guess you could consider pre-processing the input and scrubbing off the namespaces manually (ick) or looking into other xml libraries like dom4j...
–
Arnout EngelenSep 3 '11 at 16:21