xml_view: HTML/XML pretty printer and viewer

Description Usage Arguments Note References Examples

View source: R/xmlview.R

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

1
2
3
4
5
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).

Note

Large HTML or XML content may take some time to render properly. It is suggested that this function be used on as minimal of a subset of HTML/XML as possible or used in a browser context vs an IDE viewer context.

References

highlight.js, vkbeautify

Examples

1
2
3
4
5
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)
}

Example output



htmltidy documentation built on Oct. 4, 2019, 1:04 a.m.

Related to xml_view in htmltidy...