Re: [R] XML to data frame or list

From: bogdan romocea <>
Date: Mon 14 Mar 2005 - 00:58:40 EST

I managed to parse more complex XML files as well. The trick was to manually determine the position of the child nodes of interest, after which they can be parsed in a loop. For example:

doc <- xmlTreeParse("file.xml",getDTD=T,addAttributeNamespaces=T) r <- xmlRoot(doc)

#find the nodes of interest

#then read them
xmldata <- list(NULL)
for (i in 1:xmlSize(r[[2]][[1]])) {
  xmldata[[i]] <-[[2]][[1]][[i]],xmlValue))   }


> mailing list PLEASE do read the posting guide! Received on Mon Mar 14 12:46:59 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:47 EST