Use the SimpleXML extension:
<?php
$xml = '<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
</bookstore>';
$doc = simplexml_load_string($xml);
echo $doc->book->attributes()->category; // cooking
echo $doc->book->title.PHP_EOL; // Everyday Italian
echo $doc->book->title->attributes()->lang.PHP_EOL; // en
Demo
Every element will be set as a property on the root object for you to access directly. In this particular case, you can use attributes() to get the attributes of the book element.
You can see in the example that you can keep going through the levels in the same way: to get to the lang attribute in book, use $doc->book->title->attributes()->lang.