encoding of XML created de novo #142
Closed
Comments
A workaround is to create the document + root node via library(xml2)
xml <- read_xml("<people></people>")
xml_add_child(xml, "person", "Gábor Csárdi")
#> {xml_node}
#> <person>
xml_add_child(xml, "person", "Maëlle Salmon")
#> {xml_node}
#> <person>
as.character(xml)
#> [1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<people><person>Gábor Csárdi</person><person>Maëlle Salmon</person></people>\n" |
The default encoding of an xml doc is UTF-8, so I wouldn't have thought you needed to specified it. @jimhester maybe we just need to tell xml2? I'm fine with making it difficult to make xml files that are not utf-8 encoded. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I create XML de novo, the encoding is not explicitly set to UTF-8 when I send the document through
as.character()
orwrite_xml()
, even thought the text I'm putting into the nodes is. Am I missing a way to do that? This happens automatically when XML is created byread_xml()
.The text was updated successfully, but these errors were encountered: