Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XPATH question [for use with SelectNodes function in C#] [Thread Next] Re: XPATH question [for use with SelectNodes function in C#]To: NULL Date: 2/3/2005 3:20:00 PM
rapataa wrote:
> I'm trying to extract the nodes that use a specific prefix from the
> following XML:
>
> <xmldoc>
> <ww:somenode1 />
> <ww:somenode2 />
> <ww:somenode3 />
> <node>
> <ww:somenode6 />
> </node>
> <node>
> <ww:somenode6 />
> <ww:somenode12 />
> </node>
> </xmldoc>
Unless you also bind the ww prefix to a namespace URI e.g.
<xmldoc xmlns:ww="http://example.org/2005/02/whatever">
the above seems not well-formed (at least when looking at both XML 1.0
and Namespaces for XML).
> As you van see, the "ww:" nodes are used on different levels in the
> document.
>
> I'm using the following C# code:
>
> xDOC.Load(strXMLdoc);
> XmlNamespaceManager nsmgr = new XmlNamespaceManager(xDOC.NameTable);
> nsmgr.AddNamespace("ww", "http://whatever");
Make sure you use the namespace URI that is defined in the document.
> XmlNodeList NL = sDOC.DocumentElement.SelectNodes("//ww:@*");
Not sure what that XPath is supposed to select
*
selects elements with any name
ww:*
all elements in the namespace bound to the prefix ww.
--
Martin Honnen
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
