TheNetImp (thenetimp) wrote in php_dev,

SimpleXMLElement Question.

I am connecting to Amazon's S3 web service. I've created 2 buckets, and am now writing a function to get back the list of buckets from S3, and am having problems parsing the XML with simple XML.

I've got down to the bucket Node in a foreach loop as $bucketObj in the XML this Node had "Name" and "CreationDate" as XML nodes.


The problem is when I call them instead of getting a "string" variable, I have a "SimpleXMLElement" If I var dump Name it looks like

    object(SimpleXMLElement)#17 (1) {
      string(13) "JamesTest1234"

How do I get access to [0] I've tried all kinds of things. If it was ['0'] I'd know how to get it, but in this case when I try $bucketObj->Name->0 it fails I've also tried $bucketObj->Name[0].

I'm really confused. I've used SimpleXML before and hadn't had any kinds of issues like this, so any suggestions would be greatly appreaciated.

This is the XML I receive with a little modified info:
<?xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult xmlns="">
        <ID>amazon key data</ID>
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded