title: Xml PHP Get attributes and its children value
body: <p>XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;lessons&gt;
      &lt;lesson level="1" course="2"&gt;
                   &lt;name type="Dog" category="Animals"&gt;Dog name&lt;/name&gt;
            &lt;/lesson&gt;
  &lt;/lessons&gt;
  </code></pre>
  
  <p>I want to get the values saved like this:</p>
  
  <pre><code>$type = "Dog";
  $category = "Animals";
  $name = "dog name";
  </code></pre>
  
  <p>This is what I've done:</p>
  
  <pre><code>    foreach($xml-&gt;name as $name){
          $type = $name['type'];
          $category = $name['category'];
  
          echo "Type: $type Category: $category&lt;br&gt;";
          // AND TO get the text, haven't figuered it out yet.. &lt;name ..="" ..=""&gt;text&lt;/name&gt;
      }
  </code></pre>
  
  <p>But it doesn't work. Don't  get any errors neither any output. Any ideas?</p>
  
  <p>EDIT: 
  OK. I changed foreach($xml->name as $name)</p>
  
  <p>to foreach($xml->lesson->name as $name)</p>
  
  <p>so I get the values of the attribute. But now I don't know how to get the value of the children.
  I've tried this:  $xml->lesson->children()</p>
  
  <p>It prints children()</p>
  
  <p>SOLVED: $text = $xml->lesson->children();
  echo $text;</p>
  
  <p>PROBLEM WAS: I'm using utf-8 in my other code but didn't change it.</p>