我试图从XML文件看起来像这样(见下文)的数据。 我需要提取ID内部节点为节点其中type = 0。 我必须找到只有R染料溶液。 现在我可以通过xmlToList提取类型( “的test.xml”)[[3]] [[1]]和id由xmlToList( “的test.xml”)[[3]] [[4]]。 更改3〜6,9,等等 - 我可以检索所需的所有类型的和id的。 但我不知道这正确的,因为它是基于可以改变(在XML结构变化的情况下)编号。 请提出从XML提取数据的另一种更简单的方法? 或在非理想我的解决方案的任何修改? 谢谢!
<?xml version="1.0" encoding="UTF-8"?>
<image name="test1" id="367432589" width="952" height="1024" create_date="Mar 2, 2009" >
<nodes>
<node type="16" name="Target532" url="/cgi/im?id=5657" id="5657" x="67" y="45" width="153" height="69">
<alt>Synthesis1</alt>
<Appearance TextArea="Rectangle: 550" Comlex="Boolean: true" />
</node>
<node type="0" name="Target1" url="/cgi/im?id=680" id="680" x="193" y="535" width="70" height="70">
<alt>Object <b>Target1<TestingCond32</alt>
<Appearance TextArea="Rectangle: 210" Comlex="Boolean: false" />
</node>
</nodes>
<edges>
<edge type="-100" id="234523">
<alt />
<Appearance Visualization="String: Hexa" HexagonIndex="Integer: 0" />
</edge>
<edge type="-100" id="23">
<alt />
<Appearance Visualization="String: Hexa" HexagonIndex="Integer: 0" />
</edge>
</edges>
</image>
我是新来的XML和有R的基本知识,谢谢!