Php 简单XML无法成功访问名称属性
如果我运行以下代码,我有一个对象会吐出以下内容:Php 简单XML无法成功访问名称属性,php,xml,simplexml,Php,Xml,Simplexml,如果我运行以下代码,我有一个对象会吐出以下内容: print_r($xml->config->Exported->stats->children() ); SimpleXMLElement Object ( [Stat] => Array ( [0] => SimpleXMLElement Object ( [@attributes] =&
print_r($xml->config->Exported->stats->children() );
SimpleXMLElement Object
(
[Stat] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Name
[abrev] =>
[format] => 2
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Hands
[abrev] => H:
[format] => 0
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => V.total
[abrev] => V:
[format] => 0
)
)
)
我的代码是:
foreach($xml->config->Exported->stats->children() as $node){
echo $node . "<br />";
switch ( $node->getName() )
{
case 'Stat':
$stat_name = (string)$node['name'];
echo $stat_name . " | ";
break;
case 'New_Line':
echo '<hr />';
break;
}
foreach($xml->config->Exported->stats->children()作为$node){
echo$node。“
”;
开关($node->getName())
{
案件‘统计’:
$stat_name=(字符串)$node['name'];
echo$stat_name.“|”;
打破
“新线路”案例:
回声“
”;
打破
}
应该返回如下内容:
虽然这是可行的,但我的代码却不可行。简单的xml输出是否与示例中的标准xml输出不同,您知道我如何调整它以使其工作吗?xml区分大小写。“名称”和“名称”是不同的限定名称