Hello guys, I need to load an xml file into a data frame in R. The xml format is as shown below. How do I acheive the same?
<?xml version="1.0" encoding="utf-8"?><posts> <row Id="1" PostTypeId="1" AcceptedAnswerId="17" CreationDate="2010-07-26T19:14:18.907" Score="6"/></posts>
I tried the below code....It does not give the desired output. I am expecting a tabular output with the column names and their values listed below.
library(XML)
xml.url ="test.xml"
xmlfile = xmlTreeParse(xml.url)
class(xmlfile)
xmltop=xmlRoot(xmlfile)
print(xmltop)[1:2]
plantcat <- xmlSApply(xmltop, function(x) xmlSApply(x, xmlValue))
plantcat_df <- data.frame(t(plantcat))