xml question with c#

  • Thread starter Thread starter daveL
  • Start date Start date
D

daveL

i have xml like below
<ROOT>
<ITEM Name="Hello">
<SomeValue1> a </SomeValue1>
<SomeValue2> b </SomeValue2>
</ITEM>
<ITEM Name="World">
<SomeValue1> BOB </SomeValue1>
<SomeValue2> CAROL </SomeValue2>
</ITEM>
</ROOT>


How to Selectsinglenode() to get to the Node ITEM with Name = "World"
or do i have to Loop and Find it that way

Thanks
DaveL
 
daveL said:
i have xml like below
<ROOT>
<ITEM Name="Hello">
<SomeValue1> a </SomeValue1>
<SomeValue2> b </SomeValue2>
</ITEM>
<ITEM Name="World">
<SomeValue1> BOB </SomeValue1>
<SomeValue2> CAROL </SomeValue2>
</ITEM>
</ROOT>


How to Selectsinglenode() to get to the Node ITEM with Name = "World"
or do i have to Loop and Find it that way

Try:

doc.SelectSingleNode("//ROOT/ITEM[@Name='World']")

Arne
 
Thanks alot
DaveL

Arne Vajhøj said:
daveL said:
i have xml like below
<ROOT>
<ITEM Name="Hello">
<SomeValue1> a </SomeValue1>
<SomeValue2> b </SomeValue2>
</ITEM>
<ITEM Name="World">
<SomeValue1> BOB </SomeValue1>
<SomeValue2> CAROL </SomeValue2>
</ITEM>
</ROOT>


How to Selectsinglenode() to get to the Node ITEM with Name = "World"
or do i have to Loop and Find it that way

Try:

doc.SelectSingleNode("//ROOT/ITEM[@Name='World']")

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top