Extract data from xml file (declaration) using R only

Vellioxemaham

New Member
I am trying to extract data from xml file that looks like this (see below). I need to extract id inside nodes for node where type=0. I have to find solution for R only.For now I can extract type by xmlToList("test.xml")[[3]][[1]] and id by xmlToList("test.xml")[[3]][[4]]. Changing 3 to 6,9,etc - I can retrieve all of needed type's and id's. But I am not sure that this correct because it is based on numbering that can be changed (in case of xml structure change). Can you please propose another more simple way of extracting data from xml ? or any modifications on my nonideal solution? Thank's!\[code\]<?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>\[/code\]I am new to xml and have basic knowledge of R. Thank you!
 
Back
Top