title: Get specific tag with XMLReader in PHP
body: <p>I have the following XML-structure in my XML file (it's not the whole XML-file, only a part of it):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;extensions&gt;
          &lt;extension extensionkey="fp_product_features"&gt;
              &lt;downloadcounter&gt;355&lt;/downloadcounter&gt;
              &lt;version version="0.1.0"&gt;
                  &lt;title&gt;Product features&lt;/title&gt;
                  &lt;description/&gt;
                  &lt;downloadcounter&gt;24&lt;/downloadcounter&gt;
                  &lt;state&gt;beta&lt;/state&gt;
                  &lt;reviewstate&gt;0&lt;/reviewstate&gt;
                  &lt;category&gt;plugin&lt;/category&gt;
                  &lt;lastuploaddate&gt;1142878270&lt;/lastuploaddate&gt;
                  &lt;uploadcomment&gt; added related features&lt;/uploadcomment&gt;
              &lt;/version&gt;
          &lt;/extension&gt;
      &lt;/extensions&gt;
  </code></pre>
  
  <p>The file is too big for SimpleXML, so I'm using XMLReader. I have a switch that checks for the XML-tags and their content:</p>
  
  <pre><code>while ($xmlReader-&gt;read()) {
  
                  if ($xmlReader-&gt;nodeType == XMLReader::ELEMENT) {
  
                      switch ($xmlReader-&gt;name) {
  
                          case "title" :
  
                              $xmlReader-&gt;read();
                              $foo = $xmlReader-&gt;value;
                              //Do stuff with the value
  
                              break;
  
                          case  "description":
  
                              $xmlReader-&gt;read();
                              $bar = $xmlReader-&gt;value;
                             //Do stuff with the value
  
                              break;
  
                          case "downloadcounter" :
  
                              $xmlReader-&gt;read();
                              $foobar = $xmlReader-&gt;value;
                             //Do stuff with the value
  
                              break;
  
                          case "state" :
  
                              $xmlReader-&gt;read();
                              $barfoo = $xmlReader-&gt;value;
                              //Do stuff with the value
  
                          break;
  
  
                       //Repeat for other tags
  
                      }
                  }
              }
  </code></pre>
  
  <p>The problem here is that there are two <code>&lt;downloadcounter&gt;</code> tags. The one beneath <code>&lt;extension&gt;</code> and the one beneath <code>&lt;version&gt;</code>. I need the one beneath <code>&lt;version&gt;</code>, but the code in my switch is giving me the one beneath <code>&lt;extension&gt;</code>. All the other cases are giving me the right information.</p>
  
  <p>I have thought about some solutions. Maybe there is a way where I can specify that XMLReader only reads the tag after <code>&lt;description&gt;</code>? I've been using the <code>$xmlReader-&gt;read()</code> function multiple times in one case, but that didn't help.
  I'm very new to this, so maybe it is not the right the way to do it, but if anyone can point me in the right direction, it would be much appreciated.</p>
  
  <p>Thanks in advance! </p>