...

View Full Version : Getting individual information from XML array



soneen
12-10-2010, 12:56 AM
Mods, sorry for the double post, but I realized this is more of a PHP question than an XML question! I am trying to pull the individual pieces out of an xml array here is my php to get the xml:


$url="http://api.campusbooks.com/11/rest/bookprices?key=bleh&isbn=9780132080231";

$response = file_get_contents($url);
$parsed_xml = simplexml_load_string($response);

var_dump($parsed_xml);

And here is my XML (as shown by the var_dump):


object(SimpleXMLElement)#1 (3) {
["@attributes"]=>
array(2) {
["status"]=>
string(2) "ok"
["version"]=>
string(2) "11"
}
["label"]=>
object(SimpleXMLElement)#2 (1) {
["@attributes"]=>
array(2) {
["plid"]=>
string(4) "3670"
["name"]=>
string(11) "Website"
}
}
["page"]=>
object(SimpleXMLElement)#3 (3) {
["@attributes"]=>
array(1) {
["name"]=>
string(10) "bookprices"
}
["book"]=>
object(SimpleXMLElement)#4 (13) {
["isbn10"]=>
string(10) "0132080230"
["isbn13"]=>
string(13) "9780132080231"
["title"]=>
string(28) "Microeconomics (7th Edition)"
["author"]=>
string(33) "Robert Pindyck - Daniel Rubinfeld"
["binding"]=>
string(9) "Hardcover"
["msrp"]=>
string(6) "166.67"
["pages"]=>
string(3) "768"
["publisher"]=>
string(13) "Prentice Hall"
["published_date"]=>
string(10) "2008-06-21"
["edition"]=>
string(1) "7"
["rank"]=>
string(5) "58345"
["rating"]=>
string(3) "3.5"
["image"]=>
string(60) "http://ecx.images-amazon.com/images/I/51GLbJmZclL._SL75_.jpg"
}

So what is the syntax to pull out book=>edition and echo it for example? I am really struggling with this. :confused:

abduraooft
12-10-2010, 10:04 AM
It'd be easy if you give the contents of the xml file instead of var_dump() result



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum