Barta Tamás
Barta Tamás

Reputation: 899

access attribute of SimpleXMLElement Object

i got this object:

SimpleXMLElement Object\n(\n    
[@attributes] => Array\n        (\n            
  [article_number] => 550007\n        )\n\n    
[serial_number] => Array\n        (\n            
   [0] => 5500070000126237\n            
   [1] => 5500070000126246\n            
   [2] => 5500070000126255\n            
   [3] => 5500070000126264\n            
   [4] => 5500070000126273\n        )\n\n)\n

I want to access the attribute like this , but it doesn't seem to work:

foreach ($product_array as $codes) 
{    
    error_log($codes->product[0]->attributes()->article_number);    
}

Upvotes: 0

Views: 74

Answers (1)

Markus Hedlund
Markus Hedlund

Reputation: 24254

$codes->product[0]['article_number']

This should work.

Upvotes: 1

Related Questions