Learn R Programming

htmltidy (version 0.5.0)

xml_view: HTML/XML pretty printer and viewer

Description

This uses the vkbeautify and highlight.js javascript modules to format and "pretty print" HTML/XML documents, nodes, node sets and plain character HTML/XML in an htmlwidget pane.

Usage

xml_view(doc, style = "default", scroll = FALSE, add_filter = FALSE,
  apply_xpath = NULL, width = "100%", height = NULL)

html_view(doc, style = "default", scroll = FALSE, add_filter = FALSE, apply_xpath = NULL, width = "100%", height = NULL)

Arguments

doc

xml2 document/node/nodeset, an HTMLInternalDocument/ XMLInternalDocument or atomic character vector of HTML/XML content

style

CSS stylesheet to use (see higlight_styles())

scroll

should the <div> holding the HTML/XML content scroll (TRUE) or take up the full viewer/browser window (FALSE). Default is FALSE (take up the full viewer/browser window). If this is set to TRUE, height should be set to a value other than NULL.

add_filter

show an XPath input box to enable live filtering? (default: FALSE)

apply_xpath

Add and apply an XPath query string to the view. If add_filter is TRUE then this query string will appear in the filter box and be applied to the passed in document.

width

widget width (best to keep it at 100%)

height

widget height (kinda only useful for knitting since this is meant to be an interactive tool).

References

highlight.js, vkbeautify

Examples

Run this code
# NOT RUN {
if (interactive()) {
txt <- paste0("<note><to>Tove</to><from>Jani</from><heading>Reminder</heading>",
              "<body>Don't forget me this weekend!</body></note>")
# xml_view(txt)
}
# }

Run the code above in your browser using DataLab