XMLNode: Constructor function for 'XiMpLe_node' objects

View source: R/XMLNode.R

XMLNodeR Documentation

Constructor function for XiMpLe_node objects

Description

Can be used to create XML nodes.

Usage

XMLNode(
  tag_name,
  ...,
  attrs,
  shine,
  namespace,
  namespaceDefinitions,
  .children = list(...)
)

Arguments

tag_name

Character string, the tag name.

...

Optional children for the tag. Must be either objects of class XiMpLe_node or character strings, which are treated as attributes if they are named, and as simple text values otherwise. Use a named character() value for empty attributes. If this argument is empty, the tag will be treated as an empty tag. To force a closing tag, supply an empty string, i.e. "".

attrs

An optional named list of attributes. Will be appended to attributes already defined in the ... argument.

shine

A numeric integer value between 0 and 2, overwriting the shine value of, e.g., pasteXML for this particular node.

namespace

Currently ignored.

namespaceDefinitions

Currently ignored.

.children

Alternative way of specifying children, if you have them already as a list. This argument completely replaces values defined in the ... argument.

Details

To generate a CDATA node, set tag_name="![CDATA[", to create a comment, set tag_name="!--".

Note that all defined attributes will silently be dropped if a text node, CDATA node or comment is generated.

Value

An object of class XiMpLe_node.

See Also

XMLTree, pasteXML

Examples

(sample.XML.node <- XMLNode("a",
  attrs=list(
    href="http://example.com",
    target="_blank"
  ),
  .children="klick here!"
))
# This is equivalent
(sample.XML.node2 <- XMLNode("a",
  "klick here!",
  href="http://example.com",
  target="_blank"
))
# As is this
(sample.XML.node3 <- XMLNode("a",
  .children=list(
    "klick here!",
    href="http://example.com",
    target="_blank"
  )
))

rkward-community/XiMpLe documentation built on March 6, 2023, 5:28 a.m.