我有一个simpleXml对象,并希望从对象中读取数据,我是
@L_502_0@的新手,并不知道如何做到这一点.对象细节如下.
我需要阅读[描述]和[小时].谢谢.
SimpleXMLElement Object ( [@attributes] => Array ( [type] => array ) [time-entry] => Array ( [0] => SimpleXMLElement Object ( [date] => 2010-01-26 [description] => TCDM1 data management: sort & upload [hours] => 1.0 [id] => 21753865 [person-id] => 350501 [project-id] => 4287373 [todo-item-id] => SimpleXMLElement Object ( [@attributes] => Array ( [type] => integer [nil] => true ) ) ) [1] => SimpleXMLElement Object ( [date] => 2010-01-27 [description] => PDCH1: HTML [hours] => 0.25 [id] => 21782012 [person-id] => 1828493 [project-id] => 4249185 [todo-item-id] => SimpleXMLElement Object ( [@attributes] => Array ( [type] => integer [nil] => true ) ) ) ) )
请帮我.我尝试了很多东西,但没有正确的语法.
如果您可以给我们一个屏幕截图或给出行间距和缩进,那么上面的内容真的很难读,那会更好一点
如果你有一个对象
如果你有一个对象
$xml是一个simplexml对象,你可以访问像
$xml->element.
它看起来像是时间输入的元素,在这种情况下你会像这样循环:
foreach( $xml->{'time-entry'} as $time_entry ) { echo $time_entry->description . "<br />\n"; }