problems with xpath evaluate with namespaces



I'm trying to evaluate a simple xpath expression.


I have an xml object,



var xn = response.resultXML;


xn.outerHTML evaluates to:



<Result xmlns="http://url.com/services">
<AE>0</AE>
<FM>0</FM>
<OCX>0</OCX>
<TX>0</TX>
<AR>0</AR>
<Items>
<RI>
<PR>1</PR>
<Date>2003-07-19T00:00:00</Date>
<AR>228217.5600</AR>
<AQ>19018.1300</AQ>
<CBZ>13.519997630331753554502369668</CBZ>
<XN>1.1266664691943127962085308057</XN>
<AM>19018.1300</AM>
<Unit>PerMonth</Unit>
<UnitString>$/Month</UnitString>
<DD>0.0</DD>
<CR>0</CR>
</RI>
</Items>
</Result>


I'm trying to evaluate this xml using the following query. The xml is the result of a soap webservice call.



var xdoc = xn.ownerDocument;
resolver = xdoc.createNSResolver(xdoc.documentElement);
var es = xdoc.evaluate("Items", xn, resolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
var node = es.singleNodeValue


I do not get any results. Can somebody point me in the right direction to retrieve the Items node? Thanks.


EDIT -


This is the outer HTML for xn.ownerDocument.documentElement :



<soap:Envelope xmlns:soap="http://ift.tt/sVJIaE" xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY">
<soap:Body>
<Result xmlns="http://url.com/services">
<AE>0</AE>
<FM>0</FM>
<OCX>0</OCX>
<TX>0</TX>
<AR>0</AR>
<Items>
<RI>
<PR>1</PR>
<Date>2003-07-19T00:00:00</Date>
<AR>228217.5600</AR>
<AQ>19018.1300</AQ>
<CBZ>13.519997630331753554502369668</CBZ>
<XN>1.1266664691943127962085308057</XN>
<AM>19018.1300</AM>
<Unit>PerMonth</Unit>
<UnitString>$/Month</UnitString>
<DD>0.0</DD>
<CR>0</CR>
</RI>
</Items>
</Result>
</soap:Body>
</soap:Envelope>

No comments:

Post a Comment