Hi,

I am working with an XML document and have a SimpleXML object whose var_dump 
looks like this:

---
object(SimpleXMLElement)#2 (10) {
  ["@attributes"]=>
  array(1) {
    ["id"]=>
    string(7) "3854857"
  }
  ["type"]=>
  string(7) "Article"
  ["createDate"]=>
  string(25) "2006-09-06T16:42:20-07:00"
  ["editDate"]=>
  string(25) "2007-07-16T09:15:53-07:00"
  ["creator"]=>
  string(19) "Michael Gottfredson"
  ["status"]=>
  string(5) "ready"
  ["field"]=>
  ...snip a bunch of stuff...
}
---

Assuming the above object is referenced by $current_object, I can access the 
values of most stuff with $current_object->creator or whatever.  However, I 
cannot figure out how to access the value of id.  I tried the following, none 
of which worked for me:

1.  $current_object->@attributes->id (gives Parse error: syntax error, 
unexpected '@', expecting T_STRING or T_VARIABLE or '{' or '$' in 
/Applications/apache/htdocs/test.php on line 33)

2.  $current_object->'@attributes'->id (gives Parse error: syntax error, 
unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or '{' 
or '$' in/Applications/apache/htdocs/test.php on line 33)

3.  $current_object->{...@attributes}->id (no error but is null)

4.  $current_object->{'@attributes'}->id (no error but is also null)

Does anyone know how I can reference the value of id?  Thanks!

Mari
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to