Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个名为 $myXMLElement 的变量,当我转储该变量时,它看起来像这样。
SimpleXMLElement Object ( [@attributes] => Array ( [id] => 7 ) [0] => Kirkpatrick )
我如何在 PHP 中获取 Kirkpatrick 的值
你有没有尝试过:
(string) $var[0]
? 通常,您使用字符串转换来执行此操作,会将 SimpleXMLElements 转换为 XML nodeValue。
这应该得到值:
echo $myXMLElement->{'0'};