Re: [R] Need help extracting info from XML file using XML package

2009-03-02 Thread Wacek Kusnierczyk
Don MacQueen wrote: I have an XML file that has within it the coordinates of some polygons that I would like to extract and use in R. The polygons are nested rather deeply. For example, I found by trial and error that I can extract the coordinates of one of them using functions from the XML

Re: [R] Need help extracting info from XML file using XML package

2009-03-02 Thread Romain Francois
Hi, You also might want to check R4X: # install.packages(R4X, repos=http://R-Forge.R-project.org;) require( R4X ) x - xml(http://code.google.com/apis/kml/documentation/KML_Samples.kml;) coords - x[Polygon///coordinates/# ] data - sapply( strsplit( coords, (,|\\s+) ), as.numeric ) Romain

Re: [R] Need help extracting info from XML file using XML package

2009-03-02 Thread Romain Francois
Romain Francois wrote: Hi, You also might want to check R4X: # install.packages(R4X, repos=http://R-Forge.R-project.org;) require( R4X ) x - xml(http://code.google.com/apis/kml/documentation/KML_Samples.kml;) coords - x[Polygon///coordinates/# ] data - sapply( strsplit( coords, (,|\\s+) ),

Re: [R] Need help extracting info from XML file using XML package

2009-03-02 Thread Duncan Temple Lang
Wacek Kusnierczyk wrote: Don MacQueen wrote: I have an XML file that has within it the coordinates of some polygons that I would like to extract and use in R. The polygons are nested rather deeply. For example, I found by trial and error that I can extract the coordinates of one of them using

Re: [R] Need help extracting info from XML file using XML package

2009-03-02 Thread Wacek Kusnierczyk
Duncan Temple Lang wrote: Wacek Kusnierczyk wrote: Don MacQueen wrote: I have an XML file that has within it the coordinates of some polygons that I would like to extract and use in R. The polygons are nested rather deeply. For example, I found by trial and error that I can extract the

Re: [R] Need help extracting info from XML file using XML package

2009-03-02 Thread Duncan Temple Lang
Wacek Kusnierczyk wrote: Duncan Temple Lang wrote: Wacek Kusnierczyk wrote: Don MacQueen wrote: I have an XML file that has within it the coordinates of some polygons that I would like to extract and use in R. The polygons are nested rather deeply. For example, I found by trial and error

Re: [R] Need help extracting info from XML file using XML package

2009-03-02 Thread Wacek Kusnierczyk
Duncan Temple Lang wrote: not really: the xpath pattern '//coordinates' does say 'find all coordinates nodes searching from the root', but the root here is not the original root of the whole document, but each polygon node in turn. try: root = xmlInternalTreeParse(' root

[R] Need help extracting info from XML file using XML package

2009-03-01 Thread Don MacQueen
I have an XML file that has within it the coordinates of some polygons that I would like to extract and use in R. The polygons are nested rather deeply. For example, I found by trial and error that I can extract the coordinates of one of them using functions from the XML package: doc -

Re: [R] Need help extracting info from XML file using XML package

2009-03-01 Thread David Winsemius
A bit over a year ago I got useful advice from Gabor Grothendieck and Duncan Temple Lang in this thread: http://finzi.psych.upenn.edu/R/Rhelp02/archive/117140.html If the coordinates are nested deeply, then it probably safer to search for a specific tag or tags that are just above them .