I\'m querying data from an XML-based API. The API responses are paginated, so I have to make a bunch of queries to get the full data set.
Using read_xml
fro
Consider the XML package to initialize an empty document with
and iteratively append other XML content using addChildren()
method from the root of each XML.
library(XML)
doc = newXMLDoc()
root = newXMLNode("root", doc = doc)
# LOOP THROUGH 50 REQUESTS
lapply(seq(50), function(i) {
# PARSE ALL CONTENT
tmp <- xmlParse("/path/to/API/call")
# APPEND FROM API XML ROOT
addChildren(root, getNodeSet(tmp, '/apixmlroot'))
})
# SAVE TO FILE OR USE doc FOR FURTHER WORK
saveXML(doc, file="/path/to/output.xml")
I cannot find a counterpart method in xml2 as its xml_add_child
requires a character string not node(s).