Altova Mailing List Archives
>microsoft.public.xml Archive Home
>Recent entries
>Thread Prev - How to read using xpath
[Thread Next]
Re: How to read using xpath
To: NULL
Date: 9/16/2005 8:14:00 PM
Brian P wrote: > I'm trying to read this XML document: > <mserror:errorInfo > xmlns:mserror=\"http://schemas.microsoft.com/soap-toolkit/faultdetail/error/\"> If you want to use XPath with XML documents with namespaces then you need to bind the prefixes you want to use to the namespace URIs used in the XML documents and use those prefixes in the XPath expressions. So you can use an expression alike /mserror:errorInfo/mserror:returnCode but for that to work you need to make sure that the prefix mserror is bound to the URI http://schemas.microsoft.com/soap-toolkit/faultdetail/error/. How you bind the prefix to the URL depends on the tool you use to evaluate the XPath expressions, with .NET you use an XmlNamespaceManager: <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlNamespaceManagerClassTopic.asp> <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlNamespaceManagerClassAddNamespaceTopic.asp> <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlNodeClassSelectNodesTopic2.asp> With MSXML you need to use the method setProperty to set "SelectionNamespaces" as needed: <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/7854c9c3-8338-4095-b6e7-3293de636aad.asp> <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/36b6439d-e4e0-42d3-baf5-6c24e17c9ed9.asp> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Disclaimer
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

