【发布时间】:2016-03-06 08:00:00
【问题描述】:
我想将$xml->xpath 用于XML 文件。
下面的第一行成功,但第二行不起作用。
$xml = simplexml_load_string(decode(file_get_contents('http://www.file.net/name.xml')));
if($xml) {
$dataObjects = $xml->xpath('/feed/in/test[@id="0603162"]'); // First line
$xmlObjects = $dataObjects->xpath('/get/type[@name="333"]'); // Second line
print_r($xmlObjects);
}
【问题讨论】:
-
var_dump($dataObjects);返回什么? -
array(1) { [0]=> object(SimpleXMLElement)#25 (4) { ["@attributes"]=> array(7) { ["a_id"]=> string( 7)“4142502”[“ad_2”]=>字符串(7)“4503374”[“日期”]=>字符串(10)“06.03.2016”[“id”]=>字符串(7)“4260040”[ "std"]=> string(20) "060316234" ["status"] ...