ropensci / RNeXML

Implementing semantically rich NeXML I/O in R
https://docs.ropensci.org/RNeXML
Other
13 stars 9 forks source link

xml2::read_xml has changed return value to class c( "xml_document", "xml_node") #146

Closed hlapp closed 8 years ago

hlapp commented 8 years ago
> library("xml2")
> str(read_xml("<foo><bar /></foo>"))
List of 2
 $ node:<externalptr> 
 $ doc :<externalptr> 
 - attr(*, "class")= chr [1:2] "xml_document" "xml_node"
>

read_xml is what httr::content() calls to parse text/xml documents.

Apparently nexml_read() expects XMLInternalDocument or XMLInternalNode, not xml_document or xml_node. I can't figure out how to coerce the latter into the former (using as() results in an unsupported coercion error).

Can this be fixed somehow? Otherwise we're back to have to write NeXML documents pulled from APIs to temporary files first before handing them off to nexml_read().

cboettig commented 8 years ago

The httr package changed its default xml parser from XML to xml2 (& msybe the default of content became parsed instead of text I think). This should be easy to fix (but maybe not easy enough to do from my phone), https://github.com/ropensci/RNeXML/blob/master/R/nexml_read.R#L45 should have as = "text" in the call to content ...