Home > Archive > Visual Basic > October 2004 > XPath only works with DOMDocument (v. 1)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
XPath only works with DOMDocument (v. 1)
|
|
| Mike [MCP VB] 2004-10-28, 8:55 am |
| Dear all,
Jusst a quickie, I won't post the xml or the remaining code - but... just
off the top of your heads, why does the following XPath query (passed to a
VB6 DOMDocument object) fail on any DOMDocument object version that isn't
DOMDocument (i.e. DOMDocument26, 40, 50 all fail - returning nothing).
Set objNode =
oDom.selectSingleNode("//interactionId[@root=""2.16.840.1.113883.2.1.3.2.4.12""]")
The element is valid, and the XPath appears to also be valid.
Any ideas why this won't work in later versions?
Thanks!
Mike
| |
| Martin Honnen 2004-10-28, 3:55 pm |
|
Mike [MCP VB] wrote:
> Jusst a quickie, I won't post the xml or the remaining code - but... just
> off the top of your heads, why does the following XPath query (passed to a
> VB6 DOMDocument object) fail on any DOMDocument object version that isn't
> DOMDocument (i.e. DOMDocument26, 40, 50 all fail - returning nothing).
>
> Set objNode =
> oDom.selectSingleNode("//interactionId[@root=""2.16.840.1.113883.2.1.3.2.4.12""]")
>
> The element is valid, and the XPath appears to also be valid.
>
> Any ideas why this won't work in later versions?
It could be that namespaces are used in the XML document, and XPath 1.0
and namespaces are only support in MSXML 3 and later where you need to set
oDom.setProperty "SelectionLanguage", "XPath"
and then
oDom.setProperty "SelectionNamespaces",
"xmlns:prefix1='http://example.com/ns1'
xmlns:prefix2='http://example.com/ns2'"
and finally use such a prefix e.g.
oDom.selectSingleNode("//prefix1:interactionId")
that way you should get consistent results using MSXML 3, 4, 5.
--
Martin Honnen
http://JavaScript.FAQTs.com/
| |
| Mike [MCP VB] 2004-10-28, 3:55 pm |
| "Martin Honnen" <mahotrash@yahoo.de> wrote in message
news:O7TN90OvEHA.4028@TK2MSFTNGP15.phx.gbl...
> It could be that namespaces are used in the XML document, and XPath 1.0
> and namespaces are only support in MSXML 3 and later where you need to set
Indeed - the scoped default namespace looks this way...
> and finally use such a prefix e.g.
> oDom.selectSingleNode("//prefix1:interactionId")
SUPERB. Many Thanks - this solved the problem.
Mike
|
|
|
|
|