pasteXMLTag {XiMpLe} | R Documentation |
Write an XML tag
Description
Creates a whole XML tag with attributes and, if it is a pair of start and end tags, also one object as child. This can be used recursively to create whole XML tree structures with this one function.
Usage
pasteXMLTag(
tag,
attr = NULL,
child = NULL,
empty = TRUE,
level = 1,
allow.empty = FALSE,
rename = NULL,
shine = 2,
indent.by = getOption("XiMpLe_indent", "\t"),
tidy = TRUE,
as_script = FALSE,
func_name = paste0(tag, "_"),
func_rename = c(`?xml_` = "xml_", `!--_` = "comment_", `![CDATA[_` = "CDATA_",
`!DOCTYPE_` = "DOCTYPE_")
)
Arguments
tag |
Character string, name of the XML tag. |
attr |
A list of attributes for the tag. |
child |
If |
empty |
Logical, <true /> or <false></false> |
level |
Indentation level. |
allow.empty |
Logical, if |
rename |
An optional named list if the attributes in XML need to be renamed from their list names in |
shine |
Integer, controlling if the output should be formatted for better readability. Possible values:
|
indent.by |
A charachter string defining how indentation should be done. Defaults to tab. |
tidy |
Logical, if |
as_script |
Logical, if |
func_name |
A character string,
defining a function name for |
func_rename |
Named character vector defining which tags' functions should get a different name.
This makes it easier to get functions with valid names that generate special tag nodes.
Only used when |
Value
A character string.
Note
However, you will probably not want to use this function at all, as it is much more
comfortable to create XML nodes or even nested trees with XMLNode
and
XMLTree
,
and then feed the result to pasteXML
.
See Also
Examples
sample.XML.tag <- pasteXMLTag("a",
attr=list(href="http://example.com", target="_blank"),
child="klick here!",
empty=FALSE)