471,348 Members | 1,954 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Using System.Xml.XPath;

Hi, I am using Visual C# window creating an application to read an xml file.
At some point I need to use XPathNavigator and XPathNodeIterator however
when I used those subjects I get error message . I add the "System.Xml.XPath"
class however it either empty or not implemented. This problem happened also
when I was going to use FlowLayoutPanel. How I can activate the above
classes? Do I need to instal something? Thanks
--
Nejadian
Jun 27 '08 #1
5 4478
At some point I need to use XPathNavigator and XPathNodeIterator
What makes you think that? In most cass, something like XmlDocument or
XDocument work fine and don't require explicit use of either of these...
Can you state what you are trying to do? Perhaps with example (if
broken) code?
I add the "System.Xml.XPath" class
That is a namespace
however it either empty or not implemented.
The XPathNavigator base-class is abstract; there are several private
implementations, but you shouldn't generally need to use them directly.

This problem happened also when I was going to use FlowLayoutPanel.
I strongly suspect this was unrelated; you'd need to indicate the
specific (ideally copy and paste verbatim) error message to give a
meaningful answer...

Marc
Jun 27 '08 #2
This the error message I am getting: The type or namespace name
'XPathNavigator' could not be found (are you missing a using directive or an
assembly reference?)

--
Nejadian
"Marc Gravell" wrote:
At some point I need to use XPathNavigator and XPathNodeIterator
What makes you think that? In most cass, something like XmlDocument or
XDocument work fine and don't require explicit use of either of these...
Can you state what you are trying to do? Perhaps with example (if
broken) code?
I add the "System.Xml.XPath" class
That is a namespace
however it either empty or not implemented.
The XPathNavigator base-class is abstract; there are several private
implementations, but you shouldn't generally need to use them directly.

This problem happened also when I was going to use FlowLayoutPanel.
I strongly suspect this was unrelated; you'd need to indicate the
specific (ideally copy and paste verbatim) error message to give a
meaningful answer...

Marc
Jun 27 '08 #3
It sounds like you are either missing a "using" directive at the top of
the file:

using System.Xml.XPath;

Or you are missing a reference to System.Xml - but either way, you don't
necessarily need to use an XPathNavigator to edit xml...

Marc
Jun 27 '08 #4
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
--
Nejadian
"Marc Gravell" wrote:
It sounds like you are either missing a "using" directive at the top of
the file:

using System.Xml.XPath;

Or you are missing a reference to System.Xml - but either way, you don't
necessarily need to use an XPathNavigator to edit xml...

Marc
Jun 27 '08 #5
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");

}
}

Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by bdinmstig | last post: by
3 posts views Thread by Otmar Ganahl | last post: by
1 post views Thread by Sonu Kapoor | last post: by
6 posts views Thread by Derek Hart | last post: by
1 post views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.