472,119 Members | 1,313 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

XPath with prefix and local name

The following returns a system error of System.Xml.XPath.XPathException.

Dim Nodes As XmlNodeList
Nodes = doc.SelectNodes("soap:Body")

How is the XPath string formed where there is a prefix and a local name for
the node?

Thanks.
Nov 12 '05 #1
2 5149


Tom_B wrote:
The following returns a system error of System.Xml.XPath.XPathException.

Dim Nodes As XmlNodeList
Nodes = doc.SelectNodes("soap:Body")


You need to use an XmlNamespaceManager, bind that prefix to a namespace
URI and pass the namespace manager as the second argument to SelectNodes.
VB pseudo code
Dim NamespaceManager as System.Xml.XmlNamespaceManager
NamespaceManager = New System.Xml.XmlNamespaceManager(doc.NameTable)
NamespaceManager.AddNamespace("soap", "putURIHere")
doc.SelectNodes("soap:Body", NamespaceManager)
Which URI you need depends on the input XML of course.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
That works -- Thanks.
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by FaensenD | last post: by
2 posts views Thread by ree32 | last post: by
5 posts views Thread by David Thielen | last post: by
3 posts views Thread by Shawn | last post: by
2 posts views Thread by Paul | last post: by
2 posts views Thread by Monty | last post: by
1 post views Thread by sobczyk.wojciech | last post: by
4 posts views Thread by gimme_this_gimme_that | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.