[R] How to use xmlFlatListTree?

Peter Higdon peter.higdon at gmail.com
Fri Aug 26 17:19:43 CEST 2011


Dear Forum,

I haven't programmed in a while, and I'm new to R, so please keep your
answers simple.
I'm trying to analyse data in an xml file. I successfully loaded the data
into lists using:
doc <- xmlTreeParse("PSparsed.xml", getDTD = F)
I was going to write a script to traverse the tree and flatten the hierarchy
into a rectangular form to fit into a data.frame, but it seems like
xmlHashTree and xmlFlatListTree are made to do this for me. I've been
following the examples in the package specification document to figure out
how to use these functions, and I'm stuck. 

1. When I type: ls("package:XML"), xmlHashTree is listed as a function, but
xmlFlatListTree is NOT. 
Is xmlFlatListTree a function from future or previous packages that isn't
currently implemented? Am I missing something about environment specific
functions here?

2. From following the examples, I still don't understand what xmlHashTree
does, or how to make the results fit into a data.frame. Here's what I'm
trying to do, using "book.xml" from the exampleData folder in the package:

chapter title	section	title
1	    XML	1 	     The elements of an XML document
1	    XML	2	     Parsing XML
1	    XML	3	     SAX
2	    XSL	1	     templates
2	    XSL	2	     XPath expressions
2	    XSL	3	     named templates 

Can anyone please guide me how xmlHashTree is used to do this?

Thanks so much,
Peter


--
View this message in context: http://r.789695.n4.nabble.com/How-to-use-xmlFlatListTree-tp3771168p3771168.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list