title: echo simplexml object
body: <p>This question has two parts.</p>
  
  <p><strong>Part 1.</strong> Yesterday I had some code which would echo the entire content of the XML from an RSS feed. Then I deleted it from my php document, saved over it, and I am totally kicking myself.</p>
  
  <p>I believe the syntax went something like this:</p>
  
  <pre><code>$xml = simplexml_load_file($url);
  echo $xml;
  </code></pre>
  
  <p>I tried that again and it is not working, so apparently I forgot the correct syntax and could use your help, dear stackoverflow question answerers.</p>
  
  <p>I keep trying to figure out what I was doing and I am unable to find an example on Google or the PHP site. I tried the print_r($url); command, and it gives me what appears to be an atomized version of the feed. I want the whole string, warts and all. I realize that I could just type the RSS link into the window and see it, but it was helpful to have it on my PHP page as I am coding and noding.</p>
  
  <p><strong>Part 2</strong> The main reason I wanted to reconstruct this is because I am trying to parse nodes off a blog RSS in order to display it on a webpage hosted on a private domain. I posted a dummy blog and discovered an awkward formatting glitch when I failed to add a title to one of the dummy posts.</p>
  
  <p>So what does one do in this situation? I tried a little:</p>
  
  <pre><code>if(entry-&gt;title == "")
  {$entryTitle = "untitled";}
  </code></pre>
  
  <p>That did not work at all.</p>
  
  <p>Here's my entire php script for the handling of the blog:</p>
  
  <pre><code>&lt;?php
  /*create variables*/
  $subtitle ="";
  $entryTitle="";
  $html = "";
  $pubDate ="";
  /*Store RSS feed address in new variable*/
  $url = "http://www.blogger.com/feeds/6552111825067891333/posts/default";
  /*Retrieve BLOG XML and store it in PHP object*/
  $xml = simplexml_load_file($url);
  print_r($xml);
  /*Parse blog subtitle into HTML and echo it on the page*/
  $subtitle .= "&lt;h2 class='blog'&gt;" . $xml-&gt;subtitle . "&lt;/h2&gt;&lt;br /&gt;";
  echo $subtitle;
  /*Go through all the entries and parse them into HTML*/
  foreach($xml-&gt;entry as $entry){
  /*retrieve publication date*/
      $xmlDate = $entry-&gt;published;
      /*Convert XML timestamp into PHP timestamp*/
      $phpDate = new DateTime(substr($xmlDate,0,19));
      /*Format PHP timestamp to something humans understand*/
      $pubDate .= $phpDate-&gt;format('l\, F j\, Y h:i A');
      if ($entry-&gt;title == "")
      {
          $entryTitle .= "Untitled";
      }
          echo $entry-&gt;title;
      /*Pick through each entry and parse each XML tree node into an HTML ready blog post*/
          $html .= "&lt;h3 class='blog'&gt;".$entry-&gt;title . "&lt;span class='pubDate'&gt; | " .$pubDate . "&lt;/span&gt;&lt;/h3&gt;&lt;p class='blog'&gt;" . $entry-&gt;content . "&lt;/p&gt;";
      /*Print the HTML to the web page*/  
          echo $html;
      /*Set the variables back to empty strings so they do not repeat data upon reiteration*/
          $html = "";
          $pubDate = "";
  }
  ?&gt;
  </code></pre>