我有一个这样的 XML 文件
<report>
<table>
<columns>
<column name="dateTime"/>
<column name="userLogin"/>
<column name="campaignName"/>
<column name="adGroupName"/>
<column name="changes"/>
</columns>
<row dateTime="Aug 13, 2013 11:56:34 PM" userLogin="hello123" campaignName="Search Exact Parts - 2012 USA" adGroupName="12 volt razor battery" changes="Text ad changed Status changed from Enabled to Paused"/>
<row dateTime="Aug 13, 2013 11:56:34 PM" userLogin="hello123" campaignName="Search Exact Parts - 2012 USA" adGroupName="Razor Quad Battery" changes="Text ad changed Status changed from Enabled to Paused"/>
<row dateTime="Aug 13, 2013 11:56:34 PM" userLogin="hello123" campaignName="Search Exact Parts - 2012 USA" adGroupName="Razor Quad Tires" changes="Text ad changed Status changed from Enabled to Paused"/>
<row dateTime="Aug 13, 2013 11:56:34 PM" userLogin="hello123" campaignName="Search Exact Parts - 2012 USA" adGroupName="Razor Replacement Battery" changes="Text ad changed Status changed from Enabled to Paused"/>
<row dateTime="Aug 13, 2013 11:56:34 PM" userLogin="hello123" campaignName="Search Exact Parts - 2012 USA" adGroupName="Razor.com" changes="Text ad changed Status changed from Enabled to Paused"/>
</table>
</report>
我的问题是我正在尝试读取这个 XML 文件。我写的代码是,
foreach($xml->children() as $secgen=>$value){
foreach($value->columns->children() as $thrgen){
$feilds[] = $thrgen['name'];
}
$data[] = $value->row['dateTime'];
}
此代码仅读取第一行值,即“2013 年 8 月 13 日晚上 11:56:34”
即使我尝试了我所知道的所有可能的方式。但我无法以正确的方式检索方式。如果有人能解决这个问题,我将非常感激。