title: Read child node with XMLreader
body: <p>I have this XML file:</p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="UTF-8"?&gt;
     &lt;cteProc xmlns="http://www.portalfiscal.inf.br/cte" versao="1.04"&gt;
     &lt;CTe&gt;
     &lt;emit&gt;
         &lt;xFant&gt;DOW&lt;/xFant&gt;
         &lt;CNPJ&gt;456789&lt;/CNPJ&gt;
     &lt;/emit&gt;
     &lt;rem&gt;
        &lt;CNPJ&gt;777777&lt;/CNPJ&gt;
        &lt;nCFOP&gt;7101&lt;/nCFOP&gt;
     &lt;/rem&gt;
     &lt;/CTe&gt;
     &lt;protCTe versao="1.04"&gt;
     &lt;/cteProc&gt;
  </code></pre>
  
  <p>To read this file I use this C# snippet:</p>
  
  <pre><code>    string 
      XmlTextReader reader = new XmlTextReader(@"C:\Conhecimento\158_v01.04-rocCTe.xml");
          XmlNodeType type;
          while (reader.Read())
          {
              type = reader.NodeType;
              if (type == XmlNodeType.Element)
              {
                  if (reader.Name == "xFant")
                  {  reader.Read(); XFant = reader.Value; textBox1.Text = XFant;} 
  
              if (reader.Name == "nCFOP")
                  {  reader.Read(); nCFOP = reader.Value; textBox2.Text = nCFOP;} 
              }
          }
  </code></pre>
  
  <p>The code works very well, but doesn't work in the case of child nodes <code>&lt;CNPJ&gt;</code>; it only reads the first. How can I write this code to read the descendants? I have tried with something like <code>rem.CNPJ</code>.</p>
  
  <p>From other  ask  question i see this code :</p>
  
  <p>string CNPJ2,CNPJ3;</p>
  
  <pre><code>      XNamespace ns = "http://www.portalfiscal.inf.br/cte";
          var todas = from ide in XElement.Load(@"C:\136_v01.04.xml").Descendants(ns + "ide")
  
                      select new { CNPJ1 = (string)ide.Element(ns + "CNPJ") };
  
          var emit  = from ide1 in XElement.Load(@"C:\136_v01.04.xml").Descendants(ns + "emit")
  
                      select new { CNPJ2 = (string)ide1.Element(ns + "CNPJ") };
  </code></pre>
  
  <p>but How to assign "todas"  to a single variabel like int CNPJ</p>