我正在尝试遵循本指南。我可以这样打印我的 XML:
> print(deps[1:2])
$deployment
<deployment id="0">
<deploy t="0" u="2"/>
<deploy t="1" u="2"/>
<deploy t="2" u="2"/>
<deploy t="3" u="2"/>
<deploy t="4" u="5"/>
<deploy t="5" u="2"/>
<metric name="makespan" value="23"/>
<rmetric name="total_cpu_cycles" value="16340"/>
</deployment>
$deployment
<deployment id="1">
<deploy t="0" u="2"/>
<deploy t="1" u="2"/>
<deploy t="2" u="2"/>
<deploy t="3" u="2"/>
<deploy t="4" u="5"/>
<deploy t="5" u="2"/>
<metric name="makespan" value="23"/>
<rmetric name="total_cpu_cycles" value="16350"/>
</deployment>
attr(,"class")
[1] "XMLNodeList"
我想要的是一个矩阵,其中每一行都是一个部署,并且有两列('makespan','total_cpu_cycles')。
当我到达这一步时,我开始看到问题:
> depcat = xmlSApply(deps, function(x) xmlSApply(x, xmlValue))
> depcat[1,1]
[[1]]
character(0)
> str(depcat[1,1])
List of 1
$ : chr(0)