Hi,
You need to declare in the namespace manager a prefix for your
namespace and then use that prefix to qualify the references to your
element, for instance if you use md as prefix then use md:results
instead results when you call the select nodes method.
Alternatively you can use *[local-name()='results'] to ignore the
namespace but this will select any results element no matter its
namespace. You can check also the namespace if you use
*[local-name()='results' and
namespace-uri()='http://fictional.namespace.com/md']
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Dan Kelley wrote:
Quote:
I need to process a very simple xml document, but as it contains a namespace
I am finding this very difficult.
>
The xml is structured as follows:
<results xmlns="http://fictional.namespace.com/md">
<result status="true" />
<result status="true" />
<result status="false" error="error" />
</results>
>
This xml is being returned from a web service as an XmlNode. Normally I
would be able to use the code:
>
XmlNodeList results = returnInfo.SelectNodes("results");
for (int index = 0; index < results.Count; index++)
{
bool success =
XmlConvert.ToBoolean(results[index].SelectSingleNode("status").Value);
//process as appropriate
}
>
However, the presence of the namespace means the list always has a count of
0. From the docs I can see SelectNodes has an overload that additionally
accepts an XmlNamespaceManager parameter, but I cannot get this to work
either.
>
Thanks in advance.
Dan
|