powered by
This writes out both XML and normalised HTML. The default behavior will output the same format which was read. If you want to force output pass option = "as_xml" or option = "as_html" respectively.
option = "as_xml"
option = "as_html"
write_xml(x, file, ...)# S3 method for xml_document write_xml(x, file, ..., options = "format", encoding = "UTF-8")write_html(x, file, ...)# S3 method for xml_document write_html(x, file, ..., options = "format", encoding = "UTF-8")
# S3 method for xml_document write_xml(x, file, ..., options = "format", encoding = "UTF-8")
write_html(x, file, ...)
# S3 method for xml_document write_html(x, file, ..., options = "format", encoding = "UTF-8")
A document or node to write to disk. It's not possible to save nodesets containing more than one node.
Path to file or connection to write to.
additional arguments passed to methods.
default: ‘format’. Zero or more of xml2:::describe_options(xml2:::xml_save_options())
The character encoding to use in the document. The default encoding is ‘UTF-8’. Available encodings are specified at http://xmlsoft.org/html/libxml-encoding.html#xmlCharEncoding.
h <- read_html("Hi!") tmp <- tempfile(fileext = ".xml") write_xml(h, tmp, options = "format") readLines(tmp) # write formatted HTML output write_html(h, tmp, options = "format") readLines(tmp)
Run the code above in your browser using DataLab