title: LINQ to XML - Where clause
body: <p>I have an XML file with 2 types of information - Locations and job types which is determined by the <code>SLvl</code> value. I wish to bind the <code>SearchTxt</code> value for these to 2 drop downs (one for locations, one for job types) to be used as filters on my page.</p>
  
  <p>The problem is I cant quite get my where clause to filter on the <code>SLvl</code> value. With the where clause in no results are returned. If I remove it the query does return all the text values.</p>
  
  <p>C#</p>
  
  <pre><code>using System.Xml.Linq;
  using System.Linq;
  .....
  
  // Loading from file
  XDocument loaded = XDocument.Load(@"http://[LINKREMOVED]/vacancies.aspx");
  
  // Query the data
  var q = (from c in loaded.Descendants("items")
           where c.Element("SLvl").ToString() == "0"
           select c.Element("SearchTxt").ToString()).Distinct();
  
  // Populate drop down
  foreach(string name in q)
  {
      ddlLocation.Items.Add(new ListItem(name, name));
  }
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>&lt;VacancyMatch&gt;
    &lt;items&gt;
     &lt;SearchID&gt;60&lt;/SearchID&gt;
     &lt;SearchTxt&gt;Scotland&lt;/SearchTxt&gt;
     &lt;ParentID&gt;0&lt;/ParentID&gt;
     &lt;SearchCatID&gt;1&lt;/SearchCatID&gt;
     &lt;SLvl&gt;1&lt;/SLvl&gt;
     &lt;SubCat&gt;1&lt;/SubCat&gt;
    &lt;/items&gt;
    &lt;items&gt;
     &lt;SearchID&gt;92&lt;/SearchID&gt;
     &lt;SearchTxt&gt;Accounting&lt;/SearchTxt&gt;
     &lt;ParentID&gt;60&lt;/ParentID&gt;
     &lt;SearchCatID&gt;2&lt;/SearchCatID&gt;
     &lt;SLvl&gt;2&lt;/SLvl&gt;
     &lt;SubCat&gt;2&lt;/SubCat&gt;
   &lt;/items&gt;
   ... More items here
  &lt;/VacancyMatch&gt;
  </code></pre>
  
  <p>I guess the problem is that the data is at the same level? Its my first time using LINQ to XML so any help is greatly appriciated.
  Note: 
  XML is provided by a third party so formatting is up to them.</p>