[R] XML - get node by name

Antje niederlein-rstat at yahoo.de
Sun Sep 7 10:22:13 CEST 2008


Hi there,

I try to rewrite some Java-code with R. It deals with reading XML files. I 
started with the XML package. In Java, I had a very useful method which gave me 
a node by using:

name of the node
index of appearance
start point: global (false) / local (true)

So, I could do something like this.

setCurrentChildNode("data", 0);
getValueOfElement("val",1,true);
--> gives 45

setCurrentChildNode("data", 1);
getValueOfElement("val",1,true);
--> gives 11

getValueOfElement("val",1,false);
--> gives 45

<root>
   <data loc="1">
     <val i="t1"> 22 </val>
     <val i="t2"> 45 </val>
   </data>
   <data loc="2">
     <val i="t1"> 44 </val>
     <val i="t2"> 11 </val>
   </data>
</root>

Now, I'd like to do something like this in R. Most important would be to 
retrieve a node just by its name, not by the whole path. How is it possible?

Can anybody help me with this issue?

Antje



More information about the R-help mailing list