title: Getting values from XML with conditions given using C#
body: <p>I'm kinda new with using XML with C#.</p>
  
  <p>XML CODE: </p>
  
  <pre><code>&lt;LVL2&gt;
    &lt;Tables&gt;
      &lt;TBL_ID&gt;1&lt;/TBL_ID&gt;
      &lt;TBL_Name&gt;test1&lt;/TBL_Name&gt;
      &lt;MD_ID&gt;1&lt;/MD_ID&gt;
    &lt;Tables&gt;
    &lt;Tables&gt;
      &lt;TBL_ID&gt;2&lt;/TBL_ID&gt;
      &lt;TBL_Name&gt;test2&lt;/TBL_Name&gt;
      &lt;MD_ID&gt;1&lt;/MD_ID&gt;
    &lt;/Tables&gt;
    &lt;Tables&gt;
      &lt;TBL_ID&gt;3&lt;/TBL_ID&gt;
      &lt;TBL_Name&gt;test3&lt;/TBL_Name&gt;
      &lt;MD_ID&gt;1&lt;/MD_ID&gt;
    &lt;/Tables&gt;
  &lt;/LVL2&gt;
  
  &lt;LVL2&gt;
    &lt;Tables&gt;
      &lt;TBL_ID&gt;1&lt;/TBL_ID&gt;
      &lt;TBL_Name&gt;test4&lt;/TBL_Name&gt;
      &lt;MD_ID&gt;2&lt;/MD_ID&gt;
    &lt;/Tables&gt;
    &lt;Tables&gt;
      &lt;TBL_ID&gt;2&lt;/TBL_ID&gt;
      &lt;TBL_Name&gt;test5&lt;/TBL_Name&gt;
      &lt;MD_ID&gt;2&lt;/MD_ID&gt;
    &lt;/Tables&gt;
    &lt;Tables&gt;
      &lt;TBL_ID&gt;3&lt;/TBL_ID&gt;
      &lt;TBL_Name&gt;test6&lt;/TBL_Name&gt;
      &lt;MD_ID&gt;2&lt;/MD_ID&gt;
    &lt;/Tables&gt;
  &lt;/LVL2&gt;
  </code></pre>
  
  <p>How do I insert to a checkedlistbox the text values from <code>tbl_name</code> that has an <code>md_id = 1</code> only. Here is my current code.</p>
  
  <pre><code>while (xmlReader.Read())
  {
      switch (xmlReader.NodeType)
      {
  
          case XmlNodeType.Element:
              elName = xmlReader.Name;
              break;
          case XmlNodeType.Text:
  
              if (elName == "TBL_Name" &amp;&amp; MD_ID == "1")
              {
                  checkedListBox2.Items.Add(xmlReader.Value);
              }
  
              break;     
      }
  }
  </code></pre>
  
  <p>I can't seem to figure out on how to get the text that has  <code>MD_ID = "1"</code> and output:</p>
  
  <pre><code>test4
  test5
  test6
  </code></pre>