XML: A namespace prefix is claimed to be not declared when it fact it is

后端 未结 2 1224
南旧
南旧 2021-01-21 04:30

We\'ve got a web service that returns a very simple XML.




        
2条回答
  •  情歌与酒
    2021-01-21 05:05

    Surprisingly enough (for me), this is the default behaviour for XPath. By default, namespace prefixes are not allowed in an XPath query.

    To resolve this, one must register desired prefixes with SelectionNamespaces property of the DOMObject.

    objXML.setProperty("SelectionNamespaces", "xmlns:t='http://our.website.com/ns/'")
    

    After that one can use expressions qualified with t: in XPath queries. This also resolvers the original problem that forced us to use XmlNamespaceDeclarations in the first place.

提交回复
热议问题