title: C# XML) How to get values within specific tag?
body: <p>I tried ways like below but they're not working showing NullReferenceException. It seemed easy but some solutions with LINQ look complicated because I'm not familiar with LINQ and XML parsing.  </p>
  
  <p>I only want values as B1, B2, B3 and C1, C2..... within R1.(There're also R2, R3..so on.)</p>
  
  <p>What I've tried are,</p>
  
  <pre><code>string greenvalue = objDoc.Descendants("R1").First().Element("B1").Value.ToString();
  </code></pre>
  
  <p>and</p>
  
  <pre><code>string bluevalue = objDoc.XPathSelectElement("//ITEM[R1]").Element("B1").Value.ToString();
  </code></pre>
  
  <p>XML code is as below,</p>
  
  <pre><code>-&lt;RESULT&gt;
     -&lt;ITEM&gt;
        -&lt;R1&gt;
           -&lt;B DESC="product"&gt;
               &lt;B1&gt; chocolate &lt;/B1&gt;
               &lt;B2&gt; white &lt;/B2&gt;
               &lt;B3&gt; Kisses &lt;/B3&gt;
               &lt;B4&gt; bar type &lt;/B4&gt;
               &lt;B5&gt; 2 $ &lt;/B5&gt;
               &lt;B6&gt;2014-09-26 &lt;/B6&gt;
               &lt;B7&gt;201404418 &lt;/B7&gt;
            &lt;/B&gt;
           -&lt;C DESC="ingredient"&gt;
              -&lt;CR1&gt;
                  &lt;C1&gt;cacao paste &lt;/C1&gt;
                  &lt;C2&gt; concentrated &lt;/C2&gt;
                  &lt;C3&gt; 21.69 &lt;/C3&gt;
                  &lt;C4&gt; gram &lt;/C4&gt;
              &lt;/CR1&gt;
           &lt;/C&gt;
  </code></pre>