"Hollywood" <hollywood@thzero.com> wrote in message
news:O1h2DzbbEHA.904@TK2MSFTNGP09.phx.gbl...
> I have the following code that is attempting to read nodes from an xml
> file...
>
> XmlDocument xpdStatus = new XmlDocument();
> xpdStatus.Load("status.xml");
> XPathNavigator xpnStatus = xpdStatus.CreateNavigator();
>
> XPathNodeIterator xpniStatus = xpnStatus.Select("descendant::Status");
> while (xpniStatus.MoveNext())
> {
> Console.WriteLine("Book title: {0}", xpniStatus.Current.Value);
> XmlNode node = ((xpniStatus.Current) as IHasXmlNode).GetNode();
> Console.WriteLine("Status: {0}", node.Value);
> }
>
> The code works fine until I attempt to add namespaces, with prefixes, into
> the XML document, then the xpnStatus.Select never returns the Status
nodes.
> I've also tried xpnStatus.Select("descendant::Status",
> "http:///
www.mydomain.net/mynamespace") and xpnStatus.Select("Status",
> "http:///
www.mydomain.net/mynamespace") to no avail.
>
> Any thoughts?
>
> Here is a snipet of the XML...
> <?xml version="1.0" encoding="utf-8"?>
> <document xmlns:MNS="http:///
www.mydomain.net/mynamespace")>
> <MNS:Status guid="8f8ecffd-a692-493c-91d9-0074b74ca56b" damage="false"
> reset="false" save="true" show="true">
> <MNS:Name>
> <MNS:Name>Status1</MNS:Name>
> <MNS:Alias>Bl</MNS:Alias>
> </MNS:Name>
> <MNS:Description><![CDATA[Random description.]]></MNS:Description>
> </MNS:Status>
> <MNS:Status guid="b7273a52-d346-472c-8506-166f94ca896e" damage="false"
> reset="true" save="true" show="false">
> <MNS:Name>
> <MNS:Name>Status2</MNS:Name>
> <MNS:Alias>Cp</MNS:Alias>
> </MNS:Name>
> <MNS:Description><![CDATA[]]></SRD:Description>
> </SRD:Status>
> </document>
>
>