473,788 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using System.Xml.XPat h;

Hi, I am using Visual C# window creating an application to read an xml file.
At some point I need to use XPathNavigator and XPathNodeIterat or however
when I used those subjects I get error message . I add the "System.Xml.XPa th"
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 4577
At some point I need to use XPathNavigator and XPathNodeIterat or
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.XPa th" 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 XPathNodeIterat or
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.XPa th" 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.XPat h;

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.XPat h;

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.XPat h;
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.CreateNavig ator();
nav.MoveToFollo wing("some", "");
string val = nav.GetAttribut e("value", "");

// but why bother? SelectNodes / SelectSingleNod e does the job
fine...
XmlElement el = (XmlElement)doc .SelectSingleNo de("/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
6826
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 elements, attributes, ".", and "..", plus also the "" predicate format is supported - however, only one predicate per path step is supported, and expr must be a relative path. 2. Poor performance
7
8106
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: private void Page_Load(object sender, System.EventArgs e) { // load content XslTransform trans = new XslTransform();
3
2158
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 exception: _ctl1_DesktopThreePanes1_ThreePanes__ctl3_xml1: Failed! Object reference not set to an instance of an object. (The IE6.0 xml-parser transform the docbook file
1
1483
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
1728
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" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Loan"> <xs:complexType> <xs:sequence> <xs:element name="Borrower" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="BorrID" use="required">
5
17700
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 file as displayed when I open the xml file in VS .net 2003 IDE. When I perform the same procedure in C# the stream reader obkect displays a chaotic mess. Lots of whitespace after and "\r" and "\n" after each element. The problem is that I cannot...
3
6808
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> </Root> I would like to retreive "\Root\Customer\Name" out of it. Something like:
3
9170
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 really had any success. I'm pretty sure I should be casting my XPathSelect() call to something so I can get at its attributes. This seems like it should be easy, and maybe I'm missing something obvious. Does anyone have any ideas? Here is the...
6
2015
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 the make of the car. But then I pass a specific node from xmlDoc into another function, not the whole xmlDoc, just a node from it. And if I run an xpath against it, I have to use .// (has a period at the beginning) so it does not grab info from...
2
3563
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. The 'Document' configNode contains the flwg: <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10173
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
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.