Click here to Skip to main content
15,918,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<groups>
 <group name="Accounts">
    <subgroup name="Tally persons>
       <list name="AB"\>
       <list name="CD"\>
    <subgroup\>
 </group>
 <group name="Marketing">
       <list name="EF"\>
       <list name="GH"\>
 </group>
 <group name="Manager"></group>
</groups>


Here is the XML file.
Some group are have sub groups others don't.
I need the name value for the list node inside subgroup.
that AB,CD,EF,GH only.
How to get it?
Thanks
Saranya1388
Posted
Updated 2-Dec-10 22:46pm
v2
Comments
Manfred Rudolf Bihy 3-Dec-10 4:59am    
Well, all I can see is that EF and GH are list nodes that are NOT inside a subgroup tag.
The XML example is either wrong or the descriptive text is. Take your pick!
Tarun.K.S 3-Dec-10 8:13am    
but still the names can be retrieved. give the Xpath expression as //list. It will return all the list nodes!
Manfred Rudolf Bihy 3-Dec-10 9:34am    
@Tarun:What you're saying is correct, but please read my comment carefully and then check with OP's post. He's obviously having a problem with either his XML or in his description:

<quote>I need the name value for the list node inside subgroup

and then mentions nodes EF and GH also, eventhough they're not inside a subgroup tag.
Tarun.K.S 4-Dec-10 6:32am    
hmmm you are right.

1. Load xml into XmlDocument
2. Use XPath expressions to extract data from document.

Done!

This here is an excellent resource: http://www.w3schools.com/xpath/

Cheers,

Manfred
 
Share this answer
 
v2
Comments
Dalek Dave 3-Dec-10 5:00am    
Good Call.
If you're using .Net 3.0 or higher, you can use Linq-To-Xml.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900