I already had that using directive on the top and it still giving me the
error message. That is way I posted this question.l
OK, but you still haven't included nearly enough information to answer
anything here... unless you count telepathy.
An example using a navigator is below, but to be honest I've never had
to directly use a navigator, and I've done "more than a bit" of xml...
if this doesn't compile, or doesn't work (and you are sure you have
the System.Xml reference), then you are going to have to supply some
kind of information if you want help... for example:
* what version of .NET are you using? 1.1 / 2.0 / 3.0 / 3.5 / ...
* what tool are you using? VS2005 / VS2008 / csc / MSBuild / ...
* have you got a short, complete example of the code that doesn't
work? Like how mine is a short, complete example of code that works
(on my machine, at least).
Marc
using System.Xml;
using System.Xml.XPath;
static class Program {
static void Main()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(@"<xml><test><some value=""abc""/></test></xml>");
// using a navigator
XPathNavigator nav = doc.CreateNavigator();
nav.MoveToFollowing("some", "");
string val = nav.GetAttribute("value", "");
// but why bother? SelectNodes / SelectSingleNode does the job
fine...
XmlElement el = (XmlElement)doc.SelectSingleNode("/xml/test/
some");
val = el.GetAttribute("value");
}
}