469,364 Members | 2,424 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

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 5093


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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.