Skip to content

read_xml(x) throws an error if x is a textConnection() #460

Open
@trevorld

Description

@trevorld

Currently I observe that read_xml(x) throws an error if x is a textConnection().

library("xml2")
s <- '<?xml version="1.0" encoding="UTF-8"?>\n<outer>\n<inner>Inner</inner>\n</outer>'
con <- textConnection(s)
x <- read_xml(con)
Error in readBin(3L, "raw", 65536L) : 
  can only read from a binary connection

I'm aware you could use x <- read_xml(paste(readLines(con), sep = "\n")) as a workaround but this seems like an easy case to support.

I'm putting together a pull request that adds a read_xml.textConnection() S3 method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions