Using createNSResolver with multiple namespaces specified in the XML

I have an xml string such as this:\[code\]<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <ExecuteResponse xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"> <ExecuteResult i:type="a:RetrieveEntityResponse" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:ResponseName>RetrieveEntity</a:ResponseName> <a:Results xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> <a:KeyValuePairOfstringanyType> <b:key>Some Value</b:key> </a:KeyValuePairOfstringanyType> </a:Results> </ExecuteResult> </ExecuteResponse> </s:Body></s:Envelope>\[/code\]I'm trying to do something along the lines of:\[code\]var resolver = xmlDoc.createNSResolver(xmlDoc.documentElement);return new XPathEvaluator().evaluate("//b:key", xmlDoc.documentElement, resolver, XPathResult.ANY_TYPE, null);\[/code\]The key node is not being found, and the reason is when I call\[code\]resolver.lookupNamespaceURI("b")\[/code\]directly, it returns null. However, it does return something when I do\[code\]resolver.lookupNamespaceURI("s")\[/code\]so my best guess is the createNSResolver method only looks for namespaces in the root node of the xml document that is passed in. Is there any way to make it find all of the namespaces that are defined in the xml, or some other way to build a list of all of the namespaces that exist in the document?Thanks!
 
Back
Top