Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<tag1>
   <tag2>Name1</tag2>
   <value>Value1</value>
</tag1>
<tag1>
   <tag2>Name2</tag2>
   <value>Value2</value>
</tag1>
<tag1>
   <tag2>Name3</tag2>
   <value>Value3</value>
</tag1>



How can i get Name1 value without using foreach ?
Posted
Updated 2-Oct-14 17:04pm
v2
Comments
PIEBALDconsult 3-Oct-14 0:36am    
That's not all one XML document.

1 solution

After adding root tags, I used //tag1[tag2='Name1']/value to get the value.

Study up on Xpath. http://www.w3schools.com/xpath/xpath_intro.asp[^]
 
Share this answer
 
v2
Comments
strongholdx 3-Oct-14 2:27am    
thanks for this.

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