473,397 Members | 2,116 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,397 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 17 '05 #1
1 2021
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 17 '05 #2

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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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.