Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

XPath only works with DOMDocument (v. 1)
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.1
2""]")

The element is valid, and the XPath appears to also be valid.

Any ideas why this won't work in later versions?

Thanks!

Mike



Report this thread to moderator Post Follow-up to this message
Old Post
Mike [MCP VB]
10-28-04 01:55 PM


Re: XPath only works with DOMDocument (v. 1)

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/

Report this thread to moderator Post Follow-up to this message
Old Post
Martin Honnen
10-28-04 08:55 PM


Re: XPath only works with DOMDocument (v. 1)
"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



Report this thread to moderator Post Follow-up to this message
Old Post
Mike [MCP VB]
10-28-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:24 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.