【发布时间】:2010-10-07 02:21:25
【问题描述】:
当键中有空格时,有谁知道如何使用 SimpleXMLElement 解析 php 中的 xml 字符串?
例如,
$xmlString = "<test><this is>a</this is></test>";
$xml = new SimpleXMLElement($xmlString);
print_r($xml);
在上面的例子中,'this is' 导致解析器出错。我猜它是因为它认为它是一个预期的属性??
对于奖金 PT, (如果键是一个数字......像'1',同样的事情也会发生)......
【问题讨论】:
-
实际上解析器认为
is是一个属性,如解析器错误信息Entity: line 1: parser error : Specification mandate value for attribute is所示