如何从PHP中将此SimpleXMLElement中的值作为字符串获取

Say I have a variable called $myXMLElement and when I dump the variable it looks like this.

SimpleXMLElement Object ( 
    [@attributes] => Array ( [id] => 7 ) 
    [0] => Kirkpatrick 
)

How do I grab the value of Kirkpatrick in PHP

Have you tried:

(string) $var[0]

? Normally you do that with string casting, will turn SimpleXMLElements into the XML nodeValue.

This should get the value:

echo $myXMLElement->{'0'};