[R] XML to Dataframe

Duncan Temple Lang duncan at research.bell-labs.com
Tue Jun 11 17:20:34 CEST 2002


Antonio Pacheco wrote:
> Dear all,
> 
> Thank you very much for your quick replies. Actually I have seen both the XML library
> and the omegahat website, but I couldn't find such a function. Since I'm still
> learning how XML works, the example I have is the one included in the XML package,
> "mtcars.xml". But I just wanted to know if such a function already existed, so I
> wouldn't have to reinvent the wheel, writing a fuction for something that already
> exists.


Take a look at the examples/ directory in the XML package.
There should be two files named
 dataFrameEvent.R
 enhancedDataFrame.R

You can use either of them with the commands:
 source(system.file("examples", "dataFrameEvent.R", package = "XML"))
 z <-  xmlEventParse("filename", handler())
 z$data()

(changing the name of the .R file as appropriate).

These are two SAX or event based parsers that you can use to read the
mtcars.xml.  I don't appear to have provided an example using
xmlTreeParse(), but that would be less efficient and is simpler.  The
StatDataML package may provide some useful examples.

filterDataFrameEvent.R and valueFilterDataFrameEvent.R provide yet
further variants on the SAX-approach.


> 
> Thanks again
> 
> Antonio
> 
> Duncan Temple Lang wrote:
> 
> > The XML package allows one to read XML files from R and to customize
> > the input to desired input files. But there is no general way to read
> > XML and convert it to a specific data format. This is because XML
> > really is an eXtensible language and can be used to markup arbitrary
> > content. If you can tell us how the .xml file was generated and its
> > its general structure, it is possible that there are or we can create
> > handlers for a general format.
> >
> > D.
> >
> > christian wrote:
> > > Look at the package XML it is sure possible
> > > to program something, but another recommendation (sorry ... )
> > > and hard to believe come's from microsoft  & is for free !
> > >
> > > http://research.microsoft.com/~dmax/WinMine/tooldoc.htm
> > > ...here you find a file data-converter what i.e. export *.raw data
> > > in xml with several options. Further there is a interesting
> > > Bayesian Network Tool.
> > >
> > > regards,Christian
> > >
> > >
> > > Am 10.06.2002 21:13:10, schrieb Antonio Pacheco <agf2 at pitt.edu>:
> > >
> > > >Hello all,
> > > >
> > > >Is there a function to convert data stored as a .xml file to a data
> > > >frame in R?
> > > >
> > > >Thank you in advance
> > > >
> > > >Antonio
> > > >
> > > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> > > >r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> > > >Send "info", "help", or "[un]subscribe"
> > > >(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> > > >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> > > >
> > >
> > >
> > >
> > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> > > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> > > Send "info", "help", or "[un]subscribe"
> > > (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> > > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> >
> > --
> > _______________________________________________________________
> >
> > Duncan Temple Lang                duncan at research.bell-labs.com
> > Bell Labs, Lucent Technologies    office: (908)582-3217
> > 700 Mountain Avenue, Room 2C-259  fax:    (908)582-3340
> > Murray Hill, NJ  07974-2070
> >          http://cm.bell-labs.com/stat/duncan
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
_______________________________________________________________

Duncan Temple Lang                duncan at research.bell-labs.com
Bell Labs, Lucent Technologies    office: (908)582-3217
700 Mountain Avenue, Room 2C-259  fax:    (908)582-3340
Murray Hill, NJ  07974-2070       
         http://cm.bell-labs.com/stat/duncan
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list