Okay, I'm really getting frustrated. I've gotten to the point where it will return an XObject. I then call the nodelist() method and it returns a NodeList, but it's always empty. If I call getType(), it returns 4, which is a Nodeset, so that seems to be correct.
Here's the XML I'm searching against: <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>Client</faultcode> <faultstring>The SOAP message request did not contain the appropriate security token credentials required to execute a request on the server.</faultstring> <faultactor>Server</faultactor> <detail> <e:yourfaultdetails xmlns:e="mynamespace"> <message>The SOAP request did not contain a valid security token.</message> <errorcode>1000000</errorcode> </e:yourfaultdetails> </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Here's the Java code I've tried: Document doc = <load SOAP fault document>; XObject xobj = XPathAPI.eval(doc, "/SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault/faultcode", new org.apache.xml.utils.PrefixResolverDefault(doc.getDocumentElement())); NodeList nl = xobj.nodelist(); if (nl.getLength() == 0) { // always true } I've tried many variations on this. Passing in doc.getDocumentElement() instead of doc, changing the XPath expression "//SOAP-ENV:Fault/faultcode", etc. But NodeList is always empty. The ONLY time it works is when I use the expression "//faultcode", which doesn't have any namespace prefixes in it. But that won't always be an option, so I need to get the namespaces working. This has been performed on Xalan 2.2.D10 and 2.2.D13 with the same empty results. Thanks, Scott -----Original Message----- From: Voytenko, Dimitry [mailto:[EMAIL PROTECTED]] Sent: Monday, December 03, 2001 2:31 PM To: '[EMAIL PROTECTED]' Subject: RE: XPathAPI help needed Class XNodeSet is subclass of XObject, which reimplements nodelist() method. If XPath expression results in node-set, then result will be XNodeSet objects and you'll be able to use it. Thanks again, Scott -----Original Message----- From: Paul Brown [mailto:[EMAIL PROTECTED]] Sent: Monday, December 03, 2001 2:13 PM To: [EMAIL PROTECTED] Subject: RE: XPathAPI help needed > [Scott.Moore at netDecide.com] > Subject: RE: XPathAPI help needed > I've tried what you suggested, but it won't compile because the > namespaceNode (3rd parameter) must be of type Node. For instance, > Node n = XPathAPI.selectSingleNode(currentNode, xpath, > new org.apache.xml.utils.PrefixResolverDefault(contextNode)); > doesn't compile. > What am I missing here? Use the eval() method instead. Javadoc is at: http://xml.apache.org/xalan-j/apidocs/org/apache/xpath/XPathAPI.html -- PB
