0

I try too many thing to read the value of the [label] from the code below :

    Array ( [0] => 
    SimpleXMLElement Object
    (
       [id] => x 
       [published] => 2011
       [category] =>
     Array ( [0] => 
      SimpleXMLElement Object 
      ( 
      [@attributes] => 
        Array (
        [scheme] => y 
        [term] => t 
        ) )
        [1] => SimpleXMLElement Object 
        ( [@attributes] => 
        Array (
        [scheme] => y2 
        [term] => Film
        [label] => Film & Animation 
        ) )

it start with numeric array.

hakre
  • 193,403
  • 52
  • 435
  • 836
user972087
  • 665
  • 1
  • 5
  • 10
  • 1
    possible duplicate of [PHP get values from SimpleXMLElement array](http://stackoverflow.com/questions/2751711/php-get-values-from-simplexmlelement-array), see also the [Basic Usage Examples in the manual](http://fr.php.net/manual/en/simplexml.examples-basic.php). – hakre Sep 29 '11 at 23:23
  • tanx , i saw those , but it did not work for me , it has 2 dim array ... really condused :| – user972087 Sep 29 '11 at 23:40

1 Answers1

0

Isn't your answer as simple as:

$data->category['label']?

See simplexml documentation next time, all attributes are accessible from an array, and all subnodes are accessible through the object property operator.

If you have many categories, then you will have an array at "category[0]"

Mathieu Dumoulin
  • 12,126
  • 7
  • 43
  • 71