title: Use SimpleXML to parse .opf-files
body: <p>I'd like to parse the content of an <a href="http://en.wikipedia.org/wiki/EPUB#Open_Packaging_Format_2.0.1" rel="nofollow">.opf-file</a> (that's a file that contains the meta data of ebook-files - .epubs in my case) using <a href="http://www.php.net/manual/en/book.simplexml.php" rel="nofollow">SimpleXML</a>.</p>
  
  <p>However, I don't succeed getting items like <code>&lt;dc:title&gt;</code> or <code>&lt;dc:creator opf:file-as="xxx" opf:role="xxx"&gt;</code>.</p>
  
  <p>For the file hitchhiker.opf (see below) I tried the following:</p>
  
  <pre><code>&lt;?php
  $opf = simplexml_load_file("hitchhiker.opf");
  $namespaces = $opf-&gt;getNameSpaces(true);
  $dc = $opf-&gt;children($namespaces['dc']); 
  echo $dc-&gt;title;
  echo "\r\n";
  echo $dc-&gt;creator;
  ?&gt;
  </code></pre>
  
  <p>but that doesn't produce an output.</p>
  
  <p>If this can be done more easily with other tools than SimpleXML this would be fine too.</p>
  
  <p>hitchhiker.opf:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;package xmlns="http://www.idpf.org/2007/opf" unique-identifier="uuid_id"&gt;
      &lt;metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"&gt;
          &lt;dc:identifier opf:scheme="calibre" id="calibre_id"&gt;8&lt;/dc:identifier&gt;
          &lt;dc:identifier opf:scheme="uuid" id="uuid_id"&gt;36515eb7-1a25-4469-b55e-0042d45ca508&lt;/dc:identifier&gt;
          &lt;dc:title&gt;The Hitchhiker's Guide to the Galaxy&lt;/dc:title&gt;
          &lt;dc:creator opf:file-as="Adams, Douglas" opf:role="aut"&gt;Douglas Adams&lt;/dc:creator&gt;
          &lt;dc:contributor opf:file-as="calibre" opf:role="bkp"&gt;calibre (0.7.43) [http://calibre-ebook.com]&lt;/dc:contributor&gt;
          &lt;dc:date&gt;1997-06-22T07:00:00+00:00&lt;/dc:date&gt;
          &lt;dc:description&gt;SUMMARY:
  Don't panic! You're not timetripping! It's the tenth anniversary of the publication of Douglas Adams's zany, best-selling novel, and to celebrate Harmony is reissuing a special edition of this cult classic!By now the story is legendary. Arthur Dent, mild-mannered, out-to-lunch earth-ling, is plucked from his planet by his friend Ford Prefect just seconds before it was demolished to make way for a hyper-space bypass. Ford, posing as an out-of-work actor, is a researcher for the revised edition of The Hitchhiker's Guide to the Galaxy. Together the gruesome twosome begin their now-famous inter-galactic journey through time, space and best-sellerdom.For Hitchhiker fanatics (you know who you are!) who've read the books, seen the television program, and listened to the radio show, as well as newcomers to Douglas Adams's unique universe -- remember -- don't panic, don't forget to bring a towel, and don't forget to celebrate The Hitchhiker's Guide to the Galaxy's tenth anniversary by wearing your bathrobe.From the Hardcover edition.&lt;/dc:description&gt;
          &lt;dc:publisher&gt;Random House, Inc.&lt;/dc:publisher&gt;
          &lt;dc:identifier opf:scheme="ISBN"&gt;9780345418913&lt;/dc:identifier&gt;
          &lt;dc:language&gt;en&lt;/dc:language&gt;
          &lt;dc:subject&gt;Science-Fiction&lt;/dc:subject&gt;
      &lt;/metadata&gt;
      &lt;guide&gt;
          &lt;reference href="Hitchhiker's Guide to the Galaxy, The - Douglas Adams.jpg" type="cover" title="Cover"/&gt;
      &lt;/guide&gt;
  &lt;/package&gt;
  </code></pre>