Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my xml:
XML
<?xml version="1.0" encoding="utf-8"?>
<Tabel>
<Members >
<PITs>
<PIT>
  <Member>
    <Naam>Cruciatum</Naam>
    <Kills>1000</Kills>
    <Deaths>10</Deaths>
    <KD>100</KD>
  </Member>
</PIT>
</PITs>
<PITs>
<PIT>
  <Member>
    <Naam>Ghostbullet93</Naam>
    <Kills>10</Kills>
    <Deaths>1</Deaths>
    <KD>10</KD>
  </Member>
</PIT>
</PITs>
</Members>
</Tabel>


My question is that I want to extract entire member node where KD=10.Plz help me how to do it. I am using vb.net as Programming language
Posted

1 solution

Try this
C#
XDocument xdoc = XDocument.Load(@"C:\file.xml");
var results = from row in xdoc.Root.Descendants("Member")
              where int.Parse(row.Element("KD").Value) == 10
              select new XElement("Member", row.Element("Deaths"), row.Element("Kills"), row.Element("Naam"), row.Element("KD"));


Hope this helps
 
Share this answer
 
Comments
mubashir9093 5-Mar-13 7:23am    
what if KD also has a attribute
Jameel VM 5-Mar-13 8:52am    
try to read again from the result.

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