I am trying to work with XPathDocument in my code but I
tryed to assign it like the following and get an error
that it can't cast to a XmlNode. Here's the code:
XPathDocument xd = new
XPathDocument(@"D:\XML\XSL Ex2\Personnel.xml");
XPathNavigator nav = xd.CreateNavigator();
XslTransform xslt = new XslTransform();
xslt.Load(@"D:\XML\XSL Ex2\Personnel2.xsl");
StringWriter fs = new StringWriter();
xslt.Transform(xd, null, fs, null);
//select the root node
nav.MoveToRoot();
XmlNode node = nav.Select("Emps"); <- It errors
here
What do u think Oleg?
JJ
[color=blue]
>-----Original Message-----
>JJ wrote:
>[color=green]
>> I noticed that XmlNode and XpathNavigator are quite
>> similiar. XmlNode seems to navigate over an XML Doc[/color][/color]
and[color=blue][color=green]
>> so does XPathNav so when do I use XPathNavigator[/color][/color]
instead[color=blue][color=green]
>> of XmlNode?[/color]
>
>XPathNavigator is unified XPath selection facility. It[/color]
allows navigate[color=blue]
>over any XPathNavigable stores, including XmlDocument.[/color]
In fact[color=blue]
>SelectNode method's using XPathNavigator within.
>Hint: XmlDocument ios not only XML API in .NET, learn[/color]
about[color=blue]
>XPathDocument, it's gonna shadow XmlDocument soon.
>--
>Oleg Tkachenko
>XML Insider
>
http://www.tkachenko.com/blog
>
>.
>[/color]