I have used simplexml_load_string() to load into a variable an XML string and using var_dump to help me pull the required values out of it. I have done this in the past with great success but I have encountered an 'at sign' @ at the start of on of the variable names.

ex. var_dump($object);

object(SimpleXMLElement)#6 (12) {
    @attributes   => array(11) {
        clipid     => string(6) 947895
        category   => string(0) 
        channel    => string(4) Live
        preference => string(1) 1
        class      => string(4) _All
        geo        => string(4) _All
        age        => string(4) _All
        gender     => string(4) _All
        nudity     => string(1) 0
        violence   => string(1) 0
        date       => string(19) 2008-11-24T01:46:00
    }
    title         => string(27) Matt and Kim - Silver Tiles
    description   => string(89) Brooklyn's party band of choice have themselves an outrageous time at McCarren Park Pool.
    genre         => object(SimpleXMLElement)#5 (0)
    supplier      => string(12) Baeble Music
    releasestatus => object(SimpleXMLElement)#4 (0)
    keywords      => string(100) brooklyn; baeble; baeblemusic; indie-rock; indie; concert; fun; dance; happy hardcore; daylight; cro
    UgcUserId     => object(SimpleXMLElement)#11 (0)
    AllowEmbed    => string(1) 1

I can access $object->title ok but how would I access attributes? Ex, like $object->@attributes creates a syntax error and $object->attributes does not exist.

    Nevermind.

    Attributes are attributes of the actual node and can be accessed using $object['attributeName'];

      Write a Reply...