title: Simple_XML Class: Getting attribute and information on the info node
body: <p>I am pulling out information using the ANN api. I used the simpleXML class to get the information.</p>
  
  <pre><code>function explodeTest() {
              $result = $this-&gt;_restGenerator($this-&gt;ann, '6236');
              //print_r($result);
              foreach ($result-&gt;anime as $data) {
                  print_r($data-&gt;info);
              } 
          }
  </code></pre>
  
  <p>_restGenerator function:</p>
  
  <pre><code>function _restGenerator($url,$q) {
          $url = $url . strtolower($q);
          if(strlen($q) &gt; 0) {
              $q = file_get_contents($url);
              //$q = simplexml_load_file($url)
              return simplexml_load_string($q);
          }
      }
  </code></pre>
  
  <p>Constants:</p>
  
  <pre><code>$this-&gt;ann = 'http://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime=';
  </code></pre>
  
  <p>When I run the function, I get this :</p>
  
  <pre><code>SimpleXMLElement Object ( [@attributes] =&gt; Array ( [gid] =&gt; 3506750509 [type] =&gt; Picture [src] =&gt; http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A6236-259.jpg ) )
  </code></pre>
  
  <p>But the actual XML tag is displayed as this:</p>
  
  <pre><code>&lt;anime id="6236" gid="1601610894" type="TV" name="Gintama" precision="TV" generated-on="2012-07-07T04:58:39Z"&gt;
     &lt;info gid="3506750509" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A6236-259.jpg"/&gt;
     &lt;info gid="1229282479" type="Main title" lang="JA"&gt;Gintama&lt;/info&gt;
     &lt;info gid="556528412" type="Alternative title" lang="RU"&gt;Гинтама&lt;/info&gt;
     &lt;info gid="1383170257" type="Alternative title" lang="JA"&gt;銀魂&lt;/info&gt;
     &lt;info gid="380581077" type="Alternative title" lang="KO"&gt;은혼&lt;/info&gt;
     &lt;info gid="3483398015" type="Genres"&gt;action&lt;/info&gt;
     &lt;info gid="1567209986" type="Genres"&gt;adventure&lt;/info&gt;
     &lt;info gid="1221683927" type="Genres"&gt;comedy&lt;/info&gt;
     &lt;info gid="3139902810" type="Genres"&gt;drama&lt;/info&gt;
     &lt;info gid="2565080252" type="Genres"&gt;fantasy&lt;/info&gt;
     &lt;info gid="971885680" type="Genres"&gt;science fiction&lt;/info&gt;
     &lt;info gid="2312087995" type="Objectionable content"&gt;TA&lt;/info&gt;
     &lt;info gid="1950277303" type="Plot Summary"&gt;...&lt;/info&gt;
     &lt;info gid="2741727987" type="Running time"&gt;25&lt;/info&gt;
     &lt;info gid="3466023682" type="Number of episodes"&gt;201&lt;/info&gt;
     &lt;info gid="2618069239" type="Vintage"&gt;2006-04-04 to 2010-03-25&lt;/info&gt;
     &lt;info gid="820682777" type="Vintage"&gt;2007-12-04 (Italia, MTV Italia)&lt;/info&gt;
     &lt;info gid="2490517434" type="Vintage"&gt;2009-02-03 (Spain, Canal Extremadura)&lt;/info&gt;
     &lt;info gid="1770356394" type="Vintage"&gt;2009-08-30 (Malaysia, TV2)&lt;/info&gt;
     &lt;info gid="2362558760" type="Vintage"&gt;2010-01-18 (Philippines, ABS-CBN - Team Animazing)&lt;/info&gt;
     &lt;info gid="803932272" type="Vintage"&gt;2011-03-23 (Philippines - Hero, League of Heroes)&lt;/info&gt;
     &lt;info gid="2236361640" type="Vintage"&gt;2011-04-04&lt;/info&gt;
     &lt;info gid="1161326503" type="Opening Theme"&gt;#1: "Pray" by Tommy Heavenly6 (eps 1-24)&lt;/info&gt;
     &lt;info gid="2241431608" type="Opening Theme"&gt;#2: "Tooi Nioi" by YO-KING (eps 25-49)&lt;/info&gt;
     &lt;info gid="1855414862" type="Opening Theme"&gt;
  #3: "Gin-iro no Sora" (銀色の空; "Silver Sky") by redballoon (eps 50-)
  &lt;/info&gt; ...
  </code></pre>
  
  <p>When i do print_r($result) ... the info node is displayed as this</p>
  
  <pre><code>[info] =&gt; Array ( 
                      [0] =&gt; SimpleXMLElement Object ( 
                              [@attributes] =&gt; Array ( 
                                                  [gid] =&gt; 3506750509 
                                                  [type] =&gt; Picture 
                                                  [src] =&gt; http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A6236-259.jpg ) 
                                                  ) 
                      [1] =&gt; Gintama 
                      [2] =&gt; Ð“Ð¸Ð½Ñ‚Ð°Ð¼Ð° 
                      [3] =&gt; éŠ€é­‚ 
                      [4] =&gt; ì€í˜¼ 
                      [5] =&gt; action 
                      [6] =&gt; adventure 
                      [7] =&gt; comedy 
                      [8] =&gt; drama 
                      [9] =&gt; fantasy 
                      [10] =&gt; science fiction 
                      [11] =&gt; TA 
                      [12] =&gt; Twenty years ago .. &lt;synopsis&gt;
                      [13] =&gt; 25 
                      [14] =&gt; 201 
  </code></pre>
  
  <p>I need to get the type attribute of the nodes to get the array to be distinguishable, or at least filter the info node by type attribute.</p>
  
  <p>Thanks.</p>