XML to data frame



I'm trying to convert an XML document to a data frame in R. Here's what it looks like (seems pretty standard to me...):


XML document


The XML document has a schema (.xsd) as well, but I'm not sure if/how to use that.


In any case, I've tried converting the xml doc using the following code:


data <- xmlParse("drugbank.xml") drugbank_xml_data <- xmlToList(data) as_df <- ldply(drugbank_xml_data, data.frame)


Which returns an error:


Error in data.frame(description = NULL, direct-parent = "Peptides", : arguments imply differing number of rows: 0, 1


I've tried all sorts of variants (xmlTreeParse, xmlToDataFrame, etc) but nothing seems to work. If anyone has any ideas, please let me know.


No comments:

Post a Comment