Linq to XML, narrow the list based on data

  • Thread starter Thread starter Jon Q Jacobs
  • Start date Start date
J

Jon Q Jacobs

Guest
I receive xml files with a structure like the following. I want to list only the transactions without invalid data.
That is: only include transactions where the item.value.name is "invalid" and the item.value.data is blank.

Except for name and data elements, I didn't include end tags to save space. What linq query would give me this list?

<?xml version="1.0"?>
<Transactions>
<transaction>
<item>
<value>
<name>Something</name>
<data>somedata</data>
<value>
<name>that</name>
<data>thatdata</data>
<value>
<name>theother</name>
<data>theotherdata</data>
<value>
<name>invalid</name>
<data></data>
<value>
<value>
<item>
<item>
<transaction>
<item>
<value>
<name>Something</name>
<data>dataone</data>
<value>
<name>that</name>
<data>datatwo</data>
<value>
<name>invalid</name>
<data>someinvalidref</data>
<value>
<value>
<item>
<item>
<item>
<transaction>
<transaction>
<transaction>




Jon Jacobs, There are 10 kinds of people: those who understand binary and those who don't

Continue reading...
 
Back
Top