var_dump($object)
输出以下结果:
object(stdClass)#9 (5) {
["data"]=> object(stdClass)#8 {
["validFiling"]=> object(stdClass)#7 {
["indicators"]=> string(6) "MODE_S"
}
["plan"]=> object(stdClass)#6 {
["id"]=> string(10) "xxx"
}
}
}
在这个数据结构中,我需要访问字段的内容id
。我通过以下方式执行此操作:
try
{
$object = $client->getPlan($p);
var_dump($object);
}
catch (Exception $e) {
print $e->getMessage();
}
$line = $client->getLastResponse();
$doc = new DOMDocument();
$doc->loadXML($line);
$data = $doc->getElementsByTagName('data');
$fp = $data->getElementsByTagName('plan');
$id = $fp->getElementsByTagName('id');
$fId = $id->item(0)->nodeValue;
错误是(在该行$fp = $data->getElementsByTagName('plan')
):
Call to undefined method DOMNodeList::getElementsByTagName()
如何解决这个问题?