Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-10-2010, 12:56 AM   PM User | #1
soneen
New Coder

 
Join Date: Jun 2010
Posts: 54
Thanks: 4
Thanked 0 Times in 0 Posts
soneen is an unknown quantity at this point
Getting individual information from XML array

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:

PHP Code:
$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):

Code:
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.
soneen is offline   Reply With Quote
Old 12-10-2010, 10:04 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
It'd be easy if you give the contents of the xml file instead of var_dump() result
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:03 AM.


Advertisement
Log in to turn off these ads.