[R] Example for parsing XML file?

Brigid Mooney bkmooney at gmail.com
Wed May 20 22:42:28 CEST 2009


I am trying to parse XML files and read them into R as a data frame,
but have been unable to find examples which I could apply

I'm afraid I don't know much about XML, which makes this all the more
difficult.  If someone could point me in the right direction to a
resource (preferably with an example or two), it would be greatly

Here is a snippet from one of the XML files that I am looking to read,
and I am aiming to be able to get it into a data frame with columns N,
T, A, B, C as in the 2nd level of the heirarchy.

  <?xml version="1.0" encoding="utf-8" ?>
- <C S="UnitA" D="1/3/2007" C="24745" F="24648">
  <T N="1" T="9:30:13 AM" A="30.05" B="29.85" C="30.05" />
  <T N="2" T="9:31:05 AM" A="29.89" B="29.78" C="30.05" />
  <T N="3" T="9:31:05 AM" A="29.9" B="29.86" C="29.87" />
  <T N="4" T="9:31:05 AM" A="29.86" B="29.86" C="29.87" />
  <T N="5" T="9:31:05 AM" A="29.89" B="29.86" C="29.87" />
  <T N="6" T="9:31:06 AM" A="29.89" B="29.85" C="29.86" />
  <T N="7" T="9:31:06 AM" A="29.89" B="29.85" C="29.86" />
  <T N="8" T="9:31:06 AM" A="29.89" B="29.85" C="29.86" />

Thanks for any help or direction anyone can provide.

As a point of reference, I am using R 2.8.1 and have loaded the XML package.

More information about the R-help mailing list