Jump to content

Recommended Posts

hey all, im new here  :o

 

i seem to have taken leave of my senses this morning... and i am struggling to extract this array (SellerListing) from this simplexmlelement php object...

 

$Obj = SimpleXMLElement Object

(

 

[TotalResults] => 9160

[TotalPages] => 500

[sellerListing] => Array

(

[0] => SimpleXMLElement Object

(

[ExchangeId] => Y14M5526938M9611744

[ListingId] => 0309J054986

 

)

 

[1] => SimpleXMLElement Object

(

[ExchangeId] => Y14M6408230M7657367

[ListingId] => 0309J777173

)

 

[2] => SimpleXMLElement Object

(

[ExchangeId] => Y14M1914847M3622568

[ListingId] => 0604A723659

)

)

 

 

I have tried $Obj->SellerListing but that just gets the first in the array!

 

What i would love to do is foreach($Obj->SellerListing as $Item) { // blah blah

 

but all i seem to be able to do is get the first one from the array.

 

It is definitely an array!

 

*feels stupid*

 

:wtf:

It is definitely an array!

 

Sorry to break this to you but, it is not an array; the print_r() output lies.  SimpleXMLElement objects are Traversable, so you can loop over them but they're not arrays.

 

Given the output from print_r(), you should be able to use foreach($Obj->SellerListing as $Item) { // blah blah --- if that does not work, then please show the XML that you're working with (echo $Obj->saveXML();).

 

P.S. Welcome to PHPFreaks.  :shy:

thank you :) I am indeed a numpty and i have now resolved this. I tried what you said and it was still not playing ball - turns out though it was another bit of code in the loop routine that was making me "think" there was nothing there but there was!

 

Thank you for your help!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.