473,387 Members | 1,790 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,387 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 12 '05 #1
1 1459
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 12 '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
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.