元素值清空使用PHP解析XML

时间:2018-07-24 08:55:38

标签: php xml xml-parsing

要解析https://webassos.com/uploads/results/ffnex_performances_54059.xml的xml文件

<div class="custom-control custom-radio">
[radio customRadio id:customRadio1 class:custom-control-input "value4"]
<label class="custom-control-label" for="customRadio1">Something</label>
</div>
<div class="custom-control custom-radio">
[radio customRadio id:customRadio2 class:custom-control-input "value5"]
<label class="custom-control-label" for="customRadio2">Something</label>
</div>

<div class="custom-control custom-checkbox">
[checkbox checkbox1 id:customCheck1 class:custom-control-input "Value1"] 
<label class="custom-control-label" for="customCheck1">Something</label>
</div>
<div class="custom-control custom-checkbox">
[checkbox checkbox2 id:customCheck2 class:custom-control-input "value2"]
<label class="custom-control-label" for="customCheck2">Something</label>
</div>

返回具有XML元素和属性的格式正确的数组

<?php
$file = 'https://webassos.com/uploads/results/ffnex_performances_54059.xml';
$xml = simplexml_load_file($file);
print_r($xml);
?>

返回一个空对象。

与DOM文档相同的结果,并尝试通过tagName获取元素MEET。

为什么我通常使用的这种方法在这种情况下不起作用?

1 个答案:

答案 0 :(得分:0)

请检查您的结构您有一个子节点满足并且在那里找到满足

var_dump($xml->MEETS->MEET);