php - How to get an element from simplexml -


this question has answer here:

simplexmlelement object (     [smsmessage] => simplexmlelement object         (             [sid] => xyz             [dateupdated] => 2013-05-02 18:43:19             [datecreated] => 2013-05-02 18:43:19             [datesent] => 1970-01-01 05:30:00             [accountsid] => xx             [to] => 09011148771             [from] => xx             [body] => hello             [bodyindex] => simplexmlelement object                 (                 )              [status] => sending             [direction] => outbound-api             [price] => simplexmlelement object                 (                 )              [apiversion] => simplexmlelement object                 (                 )              [uri] => /v1/accounts/xx/sms/messages/xyz         )  ) 

i tried:

$xml->sid; 

but returns simplexmlelement object ( )

i tried $xml->title, returned same simplexmlelement object ( )

how sid above xml

i've been fiddling bit , recreated structure similar yours:

$string='<?xml version="1.0"?> <xml>     <smsmessage>         <sid>xyz</sid>         <dateupdated>2013-05-02 18:43:19</dateupdated>     </smsmessage> </xml>';  $xml = new simplexmlelement($string);  print_r($xml); 

this outputs:

simplexmlelement object (     [smsmessage] => simplexmlelement object     (          [sid] => xyz         [dateupdated] => 2013-05-02 18:43:19     ) ) 

which equal yours. , print xyz doing:

echo $xml->smsmessage->sid; 

try out, might missing parent node or something.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -