I have an XML document that has a fairly ordered structure (although I have nothing good, like a schema or DTD). I want to change / add / delete some of the elements of my XML file using others.
To do this, I want to take my XML file, convert it to a data framework with one row for each tag and one column per attribute, and then edit the data frame (or export to csv, change someone else, and then back off) and then convert back to XML.
Currently, this code performs the first part of converting XML to dataframe
foo<-xmlParseDoc("example.xml") bar<-xmlSApply(xmlRoot(foo), xmlAttrs, addNamespaceURLs=TRUE) tempdf<-data.frame() templist<-list() n<-1 for(i in seq(length(bar))){ message(i) if(!is.null(bar[[i]])){ message(bar[[i]]) tempdf<-rbind.fill(tempdf, data.frame(t(bar[[i]]), stringsAsFactors=FALSE)) n<-n+1 } }
but I was fixated on how to convert this framework back to the XML equivalent. Any ideas?
source share