我正在尝试返回“标签”属性的值,但没有成功。我被困了哈哈
$dom = new DOMDocument();
@$dom->loadHTML($source);
$xml = simplexml_import_dom($dom);
$code = $xml->xpath("//toolbarbutton");
var_dump($code);
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[label] => Hello World
[cmd] => redirect
[mode] => true
)
)
)
答案 0 :(得分:0)
尝试使用
$attr = $code[0]->attributes();
echo $attr['label'];