我有一些XML
要使用SimpleXmlElement
进行解析。从现在开始,所有事情都应该如此。我得到XML
和所有领域。将具有一个属性的SimpleXmlElement转换为字符串
现在我需要我已经解析值加载到database
,我使用PDO
这也是造成一些问题,因为我想拯救的SimpleXmlElement
对象到现场应该是text
。
这里是我的代码示例:
$score = $cvss->base_metrics->score;
echo $score
结果:
9.3
虽然var_dump($score)
在此函数结果使用serialize()
给
object(SimpleXMLElement)#9(1) {[0]=> string(3) "9.3"}
:
Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed
accesing [0]
场的每个尝试直接失败...我需要9.3
是字符串,以便能够创建PDO
对象。任何人都可以给我一个提示吗?
将结果强制转换为字符串:'$ score =(string)$ cvss-> base_metrics-> score;' – michi