Just wanted to add a post as to how you can extract the value from a SimpleXMLElement. Its not as straightforward as you think. Because its a complex object you can't just access the element directly. Here is a sample of data that represents a var_dump of a SimpleXmlElement
array(1) {
[0]=>
object(SimpleXMLElement)#13 (2) {
["@attributes"]=>
array(1) {
["name"]=>
string(5) "title"
}
[0]=>
string(19) "PHP Tech Book"
}
}
If you want to extract the title of the book you have to cast the specified element to a string like so.
$newTitle = (string) $title[0];
The $title variable is the SimpleXMLElement that you have extracted from the xml document using simplexml_load_string for instance. To initially access the title element from the xml document you can do like so, using xpath.
$title = $doc->xpath('str[@name="title"]');
Hope this helps someone out there.