0
我正在嘗試遵循this guide。我可以打印我的XML像這樣:使用R解析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"
我想是一個矩陣,其中每行是一個部署,有兩列(「完工」,「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)