473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

XPath querry...

Hi newsgroup!
My English is not so good please try to understand my mind 8-]

My XML file as below:
[UserAuthentication.xml]
<?xml version="1.0" encoding="UTF-8"?>
<Users>
<User name="Administrator" pwd="password"/>
<User name="Guest" pwd="guess"/>
</Users>

Here's my XPath querry:
public static void RunXPath()
{
XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(@"F:\Projects\CSharp\Freeware\DocMan\b in\Debug\UserAuthentication.xml");
XmlNodeList nodes = xmlDoc.SelectNodes(@"/Users/User[name='Administrator']");
foreach(XmlNode node in nodes)
{
Debug.WriteLine(node.OuterXml);
}
}

When i ran this code, nothing display in debug window :(

Thanks for your help,
MK

Nov 16 '05 #1
2 2070
Hello,

When I prefixed your name attribute with '@' your expression worked for
me, as follows:

xmlDoc.SelectNodes(@"/Users/User[@name='Administrator']");

Does that work for you? [You can always check the node count first to
make sure you have a match.]

- Mike

Son Ha wrote:
Here's my XPath querry:
public static void RunXPath()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"F:\Projects\CSharp\Freeware\DocMan\b in\Debug\UserAuthentication.xml");

XmlNodeList nodes =
xmlDoc.SelectNodes(@"/Users/User[name='Administrator']");
foreach(XmlNode node in nodes)
{
Debug.WriteLine(node.OuterXml);
}
}

When i ran this code, nothing display in debug window :(


Nov 16 '05 #2
Hello Mike,

Yes, it worked fine

Thanks,
MK
Hello,

When I prefixed your name attribute with '@' your expression worked
for me, as follows:

xmlDoc.SelectNodes(@"/Users/User[@name='Administrator']");

Does that work for you? [You can always check the node count first to
make sure you have a match.]

- Mike


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric Kincl | last post by:
Hello, I have an array of data in PHP. I would like to insert each member of the array into it's own row in SQL. The array is of variable length, so it would have to be dynamic code. How would...
1
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...
0
by: Costa Lino | last post by:
Hi All, I have a DataSet with xml file and I want to make a querry like this DataView dv = new DataView(mytable); dv.RowFilter = " Impression < ( MaxImpressions) "; Impression et...
1
by: Joe McIntier | last post by:
I am trying to sum the amounts attributes of a transaction element but only for transaction elements where the SaleType attribute is equal to SALE XML Snippet: <Root> <Transaction...
5
by: Clownfish | last post by:
OK, I'm having a brain freeze. I have a table like this: Office Name Phone ---------------------------------- SG Larry 555-1212 SG Moe 553-4444 SG Curly ...
1
Steve Kiss
by: Steve Kiss | last post by:
Hi. I am developping a site for which one of the pages uses querry strings to pass some parameters. I can use the querry strings if I call the page from a plain html anchor. However, when I add the...
1
by: nj2md | last post by:
Can some one assist with a querry. I need to know the code to querry a database to find the number of female and males that make over 50K a year and how to get capital gains and loses from the same...
0
by: getmeidea | last post by:
I have the following tables, 1> employee_master(emp_id int primary key, emp_name varchar(100)); 2> employee_salary_payment(salary_rid int primary key, emp_id int, sal_date date, paid_amt int); ...
2
by: dipalichavan82 | last post by:
i came across a article, where it was mentioned if we want a dynamic querry to fire then use parameterized querry e.g. string inputcity=textbox.text; SqlCommand cmd = new SqlCommand("select * from...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.