title: Getting Specific Data from XML with Generic Tags
body: <p>Most tutorials I have found on doing this are based on xml that actually has useful tags. I'm trying to get a whole set of records based on one entry in the set, with XML that has very generic tags.</p>
  
  <pre><code>//saved as thisxml.xml in current directory
  //note the empty entry in the second row
  /*
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Note&gt;
      &lt;ROW&gt;
          &lt;ENT&gt;up&lt;/ENT&gt;
          &lt;ENT&gt;Medium&lt;/ENT&gt;
          &lt;ENT&gt;Red&lt;/ENT&gt;
          &lt;ENT&gt;down&lt;/ENT&gt;
          &lt;ENT&gt;Medium&lt;/ENT&gt;
      &lt;/ROW&gt;
      &lt;ROW&gt;
          &lt;ENT&gt;right&lt;/ENT&gt;
          &lt;ENT&gt;High&lt;/ENT&gt;
          &lt;ENT&gt;Purple&lt;/ENT&gt;
          &lt;ENT/&gt;
          &lt;ENT&gt;High&lt;/ENT&gt;
      &lt;/ROW&gt;
  &lt;/Note&gt;
  */
  </code></pre>
  
  <pre><code>using System;
  using System.Linq;
  using System.Xml.Linq;
  
  namespace ParseGenericXML
  {
      class Program
      {
          static void Main(string[] args)
          {
              XDocument document = XDocument.Load("thisxml.xml");
              var selectRow = from r in document.Where(r=&gt;(string)r.Element("ENT").Value=="Purple")
              select new
              {
                  value1 = r.Element("ENT").Value,
                  value2 = r.Element("ENT").Value,
                  value3 = r.Element("ENT").Value,
                  value4 = r.Element("ENT").Value,
                  value5 = r.Element("ENT").Value
              };
  
              //selectRow results should be {"right","High","Purple",null,"High"}                   
          }
      }
  }
  </code></pre>