473,407 Members | 2,312 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,407 software developers and data experts.

Pointing to the exact node


Hi all,

I have a xml document like this.
<table>
<username>xyz</username>
<password>abc</password>
</table>
<table>
<username>pqr</username>
<password>mnp</password>
</table>

How can I point to node username where user is "pqr"? Subsequently load all
the childnoes in a nodelist. A bit of C# code will be helpful.

Thanks in advance for the help .
Praveen Naregal
Nov 12 '05 #1
1 1011
Praveen - the first and second part of your question don't seem to relate,
but i'll assume you mean find the table element that has a child user
element (which contains username and password child elements) with the text
"pqr". Correct?

Here is a quick sample - let me know if you need anything more.

XPathDocument myXPathDocument = new XPathDocument("mydocUrl.xml");
XPathNavigator myXPathNavigator = myXPathDocument.CreateNavigator();

string xpathexpr = "/table[username::text()='pqr']";
//string xpathexpr = "/table[username/text()='pqr']";

XPathNodeIterator myXPathNodeIterator = myXPathNavigator.Select
(xpathexpr);

while (myXPathNodeIterator.MoveNext())
{
Console.WriteLine("<" + myXPathNodeIterator.Current.Name + "> " +
myXPathNodeIterator.Current.Value);
}

Console.WriteLine();
Steven
Founder, http://venturetogether.com

"Praveen Naregal" <pg*******@hotmail.com> wrote in message
news:e7**************@TK2MSFTNGP09.phx.gbl...

Hi all,

I have a xml document like this.
<table>
<username>xyz</username>
<password>abc</password>
</table>
<table>
<username>pqr</username>
<password>mnp</password>
</table>

How can I point to node username where user is "pqr"? Subsequently load all the childnoes in a nodelist. A bit of C# code will be helpful.

Thanks in advance for the help .
Praveen Naregal

Nov 12 '05 #2

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

Similar topics

0
by: Bengt Richter | last post by:
I think for some purposes it might be handy to have and exact value representation in the compiler parse tree, without having to use strings as carrier. I.e., >>> from exactdec import ED >>>...
1
by: Andy | last post by:
OK, I'm not sure what I'm missing here. I'm working with this XML: <?xml version="1.0" encoding="utf-8"?> <GroupDataBlock xmlns="http://www.acme.com/data.dtd"> <GroupInfo>...
1
by: Brett Foster | last post by:
This must have been covered a million times, but I'll be damned if I can find the right information. Right now I'm using the following code: This is a function to recusively calculate the...
2
by: Paul Colton | last post by:
how can my code determine the exact line and column of an XmlNode if I need to generate and error for that node?
6
by: Chuck | last post by:
What's the difference between using "catalog node" and catalog admin node"? -- Chuck Remove "_nospam" to reply by email
6
by: Andy | last post by:
I'm making a drag and drop application, and in the *_DragDrop(...)-method I have the following code: private void SelectTree_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) {...
0
by: NTPT | last post by:
Hi. i have table like this: create table my_data ( cond_1 int8,cond_2 varchar(),cond_3 .... cond_n whatrver ,data text) This table represents a simple tree structure with known max level...
16
by: mailforpr | last post by:
How do I do that? The thing is, the only information I have about the iterator is the iterator itself. No container it is belonging to or anything. Like template<Iteratorvoid...
7
by: william | last post by:
My question is: Specific memory block where my pointer pointing to changed strangely, seemingly that no statement changed it. Here are two examples I got: ***********1***************** I was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...
0
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...

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.