reading xml file using xmlreader
<p>i have xml file, i want to retrieve the brandname  when brandcode is 001 from the following xml.</p>

<pre><code>    &lt;Root&gt;
-   &lt;data&gt;
  &lt;Companycode&gt;TF&lt;/Companycode&gt; 
  &lt;Productcode&gt;00001&lt;/Productcode&gt; 
  &lt;Productname&gt;VPU&lt;/Productname&gt; 
  &lt;Brandcode&gt;001&lt;/Brandcode&gt; 
  &lt;Brandname&gt;DB&lt;/Brandname&gt; 
  &lt;/data&gt;
- &lt;data&gt;
  &lt;Companycode&gt;TF&lt;/Companycode&gt; 
  &lt;Productcode&gt;00002&lt;/Productcode&gt; 
  &lt;Productname&gt;SENDERCARD&lt;/Productname&gt; 
  &lt;Brandcode&gt;002&lt;/Brandcode&gt; 
  &lt;Brandname&gt;LINSN&lt;/Brandname&gt; 
  &lt;/data&gt;
&lt;/Root&gt;
</code></pre>

<p>i used the following code,  here 001 is static, i used string brandname; how to assign the brandname value here</p>

<pre><code>XmlTextReader textReader = new XmlTextReader(@"codedata.xml");
            textReader.Read();

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(textReader);

            XmlNodeList BCode = xmlDoc.GetElementsByTagName("Brandcode");
            XmlNodeList BName = xmlDoc.GetElementsByTagName("Brandname");
            for (int i = 0; i &lt; BCode.Count; i++)
            {
                if (BCode[i].InnerText =="001")
                {
                    string brandname = BName[i].InnerText;
                }
                    //Console.WriteLine(BName[i].InnerText);
            }
</code></pre>
