title: echo xml with tags on html
body: <p>I am trying to echo xml and I cant mange to echo the xml tags
  ,this is my code</p>
  
  <pre><code>    &lt;?php
      // set feed URL
      $feedURL = 'http://gdata.youtube.com/feeds/api/videos?orderby=updated&amp;vq=rihana';
  
      // read feed into SimpleXML object
      $sxml = simplexml_load_file($feedURL);
      ?&gt;
        &lt;h1&gt;&lt;?php echo $sxml-&gt;title; ?&gt;&lt;/h1&gt;
      &lt;?php
      $xml = new SimpleXMLElement('&lt;xml&gt;&lt;/xml&gt;');
  
      // iterate over entries in feed
      foreach ($sxml-&gt;entry as $entry) {
        // get nodes in media: namespace for media information
        $media = $entry-&gt;children('http://search.yahoo.com/mrss/');
  
        // get video player URL
        $attrs = $media-&gt;group-&gt;player-&gt;attributes();
        $watch = $attrs['url']; 
  
        // get video thumbnail
        $attrs = $media-&gt;group-&gt;thumbnail[0]-&gt;attributes();
        $thumbnail = $attrs['url']; 
  
         $track = $xml-&gt;addChild('item');
          $track-&gt;addChild('description',  $media-&gt;group-&gt;description);
          $track-&gt;addChild('title', $media-&gt;group-&gt;title);
          $track-&gt;addChild('url', $watch);
  
      }  
      ?&gt;
       &lt;p&gt;
          &lt;?php       
           header('Content-type: text/xml');
  
  
  echo( htmlentities( $xml-&gt;asXML() ) );
  
      foreach ($xml-&gt;item as $record) {
          echo '&lt;div class="item_record"&gt;'."\n";
          echo '&lt;h3&gt;'.$record-&gt;title.'&lt;/h3&gt;'."\n";
          echo '&lt;p&gt;&lt;span class="category"&gt;description: &lt;/span&gt;'.$record-&gt;description.'&lt;/p&gt;'."\n";
          echo '&lt;p&gt;&lt;span class="category"&gt;url: &lt;/span&gt;&lt;a href='.$record-&gt;url.'&gt;'.$record-&gt;url.'&lt;/a&gt;&lt;/p&gt;'."\n";
  
          echo '&lt;/div&gt;'."\n";
      }?&gt; 
  
          &lt;/p&gt;
  </code></pre>
  
  <p>i really want to print the data in xml format its like a mix from the code below </p>
  
  <pre><code>echo( htmlentities( $xml-&gt;asXML() ) );
  </code></pre>
  
  <p>and look nice like</p>
  
  <pre><code>        foreach ($xml-&gt;item as $record) {
          echo '&lt;div class="item_record"&gt;'."\n";
          echo '&lt;h3&gt;'.$record-&gt;title.'&lt;/h3&gt;'."\n";
          echo '&lt;p&gt;&lt;span class="category"&gt;description: &lt;/span&gt;'.$record-&gt;description.'&lt;/p&gt;'."\n";
          echo '&lt;p&gt;&lt;span class="category"&gt;url: &lt;/span&gt;&lt;a href='.$record-&gt;url.'&gt;'.$record-&gt;url.'&lt;/a&gt;&lt;/p&gt;'."\n";
  
          echo '&lt;/div&gt;'."\n";
      }?&gt; 
  </code></pre>
  
  <p>which operation is the best to solve my problem?</p>