473,499 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4559
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6812
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
7
8078
by: mike p. | last post by:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl stylesheets to do xhtml transform. Transform works fine when using MSXML. When I try to do the following using asp.net 1.1: ...
3
2133
by: Otmar Ganahl | last post by:
Hi! In my application I transform a docbook file to a html view using the webcontrol "Xml" (with a xsl).It works fine, except the using of the tag "fileref" in the docbook-file will cause an...
1
1457
by: Sonu Kapoor | last post by:
Hi, I would like to use xpath with xslt. I know that this should be possible, but I dont get it ! Here is what I have tried so far: ==================================== my xml file:...
0
1703
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
5
17682
by: Drew Yallop | last post by:
I read an XML file with a stream reader in VB.Net. When I look at the stream reader output in debug mode (by passing cursor over the stream reader object)the format is a perfect replica of the...
3
6771
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer>...
3
9150
by: Brian | last post by:
Using external XML, I'm trying to build a quiz, but I can't seem to specify the DataSource for the RadioButtonList within a Repeater ItemTemplate. I've tried a number of approaches, but I haven't...
6
1997
by: Derek Hart | last post by:
I bring in an xml file into vb.net by using xmlDoc.LoadXml(XMLString) - I run xpath statements against the xml file to grab data from it, so I use, as an example, //Vehicles/Vehicles/@make to get...
2
3550
by: luthriaajay | last post by:
I need some help to extract the LatestFillQuantity element value using XPATH. in Java. I am unable to extract the value of 10000. Please help as to what have I done wrong.? Help appreciated. ...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.