Found the answer...
XPathDocument doc = new XPathDocument( "name of XML file");
XPathNavigator nav = doc.CreateNavigator();
XmlNamespaceManager ns = new XmlNamespaceManager( nav.NameTable);
ns.AddNamespace( "usr", "http://tempuri.org/Users.xsd");
XPathExpression expr = nav.Compile( "//user:Users");
expr.SetContext( ns);
XPathNodeIterator nodes = nav.Select( expr);
The XPathNavigator object has a NameTable property. Hope that is helpful
to anyone having the same problem I was having.
LuAnn
LuAnn Bradford wrote:
I have read the messages about adding namespaces, but have not found how
to do so when using an XPathDocument instead of an XmlDocument.
I have an application that writes a dataset using WriteXML. The file
contains a default namespace. A second application reads the file using
the XPathDocument Load method. My Select expression will not work with
the default namespace.
I am very new to this and would appreciate any help!
LuAnn