473,396 Members | 1,990 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.

searching for xml nodes

Hi all,
Following is a sample code from my xml file.

<w:body>
<ns0:Mpi>
<ns0:User>
<ns0:Address1>

</ns0:Address1>
</ns0:User>
</ns0:Mpi>
</w:body>

I first need to reference the User node and I am able to achieve it using
the following line. When this line executes, I do have nodeListTable
variable referencing the User node.
XmlNodeList nodeListTable =
nodeDataset.SelectNodes("//ns0:User",coverLetterSectionTemplateMamespaceManag er);

But then I need to reference the Address1 node using the above nodeListTable
variable. I tried the following line

XmlNodeList nodeListField =
nodeListTable[0].SelectNodes("//ns0:*",coverLetterSectionTemplateMamespaceManager)

But after this line executes the nodeListField variable contains all nodes
in the ns0 namespace including Mpi and User nodes. So my question is how can
I select Address1 node from nodeListTable variable using SelectNodes
function?

Thanks in advance.


Nov 19 '05 #1
2 1246
When you loop over the XmlNodes in the list, just issue a SelectSingleNode("./Address").
This will be executed in the context of the User node (from your list).

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi all,
Following is a sample code from my xml file.
<w:body>
<ns0:Mpi>
<ns0:User>
<ns0:Address1>
</ns0:Address1>
</ns0:User>
</ns0:Mpi>
</w:body>
I first need to reference the User node and I am able to achieve it
using
the following line. When this line executes, I do have nodeListTable
variable referencing the User node.
XmlNodeList nodeListTable =
nodeDataset.SelectNodes("//ns0:User",coverLetterSectionTemplateMamespa
ceManager);
But then I need to reference the Address1 node using the above
nodeListTable variable. I tried the following line

XmlNodeList nodeListField =
nodeListTable[0].SelectNodes("//ns0:*",coverLetterSectionTemplateMames
paceManager)

But after this line executes the nodeListField variable contains all
nodes in the ns0 namespace including Mpi and User nodes. So my
question is how can I select Address1 node from nodeListTable variable
using SelectNodes function?

Thanks in advance.


Nov 19 '05 #2
Try the following:

nodeListTable[0].SelectNodes("./ns0:*",coverLetterSectionTemplateMamespaceManager)

The period selects the current node, so this expression will select all
"ns0:*" nodes that are children of the current node.

BTW, you don't have to use SelectNodes() at all. Since nodeListTable[0]
already return a single node, why don't you just use that node's child node
collection. For your XML sample document below

nodeListTable[0].FirstChild

will also give you what you need.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"helpful sql" <no****@stopspam.com> wrote in message
news:ep*************@TK2MSFTNGP12.phx.gbl...
Hi all,
Following is a sample code from my xml file.

<w:body>
<ns0:Mpi>
<ns0:User>
<ns0:Address1>

</ns0:Address1>
</ns0:User>
</ns0:Mpi>
</w:body>

I first need to reference the User node and I am able to achieve it using
the following line. When this line executes, I do have nodeListTable
variable referencing the User node.
XmlNodeList nodeListTable =
nodeDataset.SelectNodes("//ns0:User",coverLetterSectionTemplateMamespaceManag er);

But then I need to reference the Address1 node using the above
nodeListTable variable. I tried the following line

XmlNodeList nodeListField =
nodeListTable[0].SelectNodes("//ns0:*",coverLetterSectionTemplateMamespaceManager)

But after this line executes the nodeListField variable contains all nodes
in the ns0 namespace including Mpi and User nodes. So my question is how
can I select Address1 node from nodeListTable variable using SelectNodes
function?

Thanks in advance.

Nov 19 '05 #3

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

Similar topics

1
by: helpful sql | last post by:
Hi all, Following is a sample code from my xml file. <w:body> <ns0:Mpi> <ns0:User> <ns0:Address1> </ns0:Address1> </ns0:User>
1
by: smita | last post by:
Hi, I want to search an xml file for particular searchstrings and also based on the date i.e. all items containing the date -----prior to the specified date, or ----on that date or ----- after the...
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
3
by: LC | last post by:
Hello all, Ive been using the treeview and for testing purpose i have created 2 Parent Nodes and 5 child nodes within each parent node i.e.- CN = Child Node Parent Node - CN - CN - CN
3
by: juvi | last post by:
Hi, I have got a problem with Treeview.Nodes.Clear() under VB2005. When I have some nodes in my treeview and a force to clear() all nodes then it seems to work, because the nodes are not visible....
1
by: Daniel Rucareanu | last post by:
Hello, Does anybody knows how can you delete, in just one step, not using a loop, a subset of the child nodes of a given DOM parent node? The subset will be continous, so for example, if the...
15
by: Gigs_ | last post by:
Hi all! I have text file (english-croatian dictionary) with words in it in alphabetical order. This file contains 179999 words in this format: english word: croatian word I want to make...
1
by: j_depp_99 | last post by:
I would like to know what would be the best way to count the nodes accessed while searching for an item in a binary search tree. I have to keep a tally for each item I search for. I have included...
10
by: John Rogers | last post by:
This code only counts the parent nodes or rootnodes in a treeview, how do you count all the nodes in a treeview? // one way int NodeCounter = 0; foreach (TreeNode currentNode in...
1
Sl1ver
by: Sl1ver | last post by:
I've implemented search for my nodes if found it will highlight the node yellow but the nodes is programed to show information about it after its selected how will i achieve the information to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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
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...
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...

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.