rendered paste body<?php
$library = <<<XML
<library>
<metaInfo>
<owner>Paul Reinheimer</owner>
<location>Montreal</location>
<tag>My Books</tag>
</metaInfo>
<books>
<book>
<author>Paul Reinheimer</author>
<title>Professional Web APIs with PHP</title>
</book>
<book>
<author>Orson Scott Card</author>
<title>Ender's Game</title>
</book>
<book>
<author>Tom Hold</author>
<title>In Your Dreams</title>
</book>
</books>
</library>
XML;
$tempname = tempnam('/tmp', 'XML_');
file_put_contents($tempname, $library);
if (!function_exists('simplexml_load_file')){
die("Simple xml is not available.");
}
$xml = simplexml_load_file($tempname);
echo '<pre>';print_r($xml);
echo 'Location is: ' . $xml->metaInfo->location;
echo '<br />';
echo 'Title of book 3 is: ' . $xml->books->book[2]->title;
unlink($tempname) ;
exit;
?>