Rev 8141 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{xmlNode}\alias{xmlNode}\alias{xmlTextNode}\alias{xmlPINode}\alias{xmlCDataNode}\alias{xmlCommentNode}\title{Create an XML node}\description{These functions allow one to create XML nodesas are created in C code when reading XML documents.Trees of XML nodes can be constructed andintegrated with other trees generated manuallyor with via the parser.}\usage{xmlNode(name, ..., attrs=NULL, namespace="", namespaceDefinitions = NULL,.children = list(...))xmlTextNode(value, namespace="", entities = XMLEntities, cdata = FALSE)xmlPINode(sys, value, namespace="")xmlCDataNode(...)xmlCommentNode(text)}\arguments{\item{name}{The tag or element name of the XML node. This is what appearsin the elements as \code{<name> .. </name>}}\item{\dots}{The children nodes of this XML node.These can be objects of class \code{XMLNode}or arbitrary values that will be converted to a stringto form an \code{XMLTextNode} object.}\item{.children}{an alternative mechanism to specifying the childrenwhich is useful for programmatic use when one has the childrenin an existing list. The \dots mechanism is for use when thechildren are specified directly and individually.}\item{attrs}{A named character vector giving thename, value pairs of attributes for this XML node.}\item{value}{This is the text that is to be used when formingan \code{XMLTextNode}.}\item{cdata}{a logical value which controls whether the textbeing used for the child node is to be firstenclosed within a CDATA node to escape special characters suchas \code{>} and \code{&}.}\item{namespace}{The XML namespace identifier for this node.}\item{namespaceDefinitions}{a collection of name space definitions, containing the prefixes and the corresponding URIs.This is most conveniently specified as a character vector whose names attribute is the vector of prefixesand whose values are the URIs. Alternatively, one can provide a list of name space definition objectssuch as those returned}\item{sys}{the name of the system for which the processing instructionis targeted. This is the value that appears in the\code{<?sys value?>}}\item{text}{character string giving the contents of the comment.}\item{entities}{a character vector giving the mappingfrom special characters to their entity equivalent.This provides the character-expandedentity pairings of 'character = entity' , e.g. '<' = "lt" which areused to make the content valid XMLso that it can be used within a text node.The text searched sequentiallyfor instances of each character in the names and each instance isreplaced with the corresponding '&entity;' }}\value{An object of class \code{XMLNode}.In the case of \code{xmlTextNode},this also inherits from \code{XMLTextNode}.The fields or slots that objectsof these classes haveinclude\code{name}, \code{attributes}, \code{children} and \code{namespace}.However, one shouldthe accessor functions\code{\link{xmlName}},\code{\link{xmlAttrs}},\code{\link{xmlChildren}}and\code{\link{xmlNamespace}}}\references{\url{https://www.w3.org/XML/}, \url{http://www.jclark.com/xml/},\url{https://www.omegahat.net} }\author{ Duncan Temple Lang }\seealso{\code{\link{addChildren}}\code{\link{xmlTreeParse}}\code{\link{asXMLNode}}\code{\link{newXMLNode}}\code{\link{newXMLPINode}}\code{\link{newXMLCDataNode}}\code{\link{newXMLCommentNode}}}\examples{# node named arg with two children: name and defaultValue# Both of these have a text node as their child.n <- xmlNode("arg", attrs = c(default="TRUE"),xmlNode("name", "foo"), xmlNode("defaultValue","1:10"))# internal C-level node.a = newXMLNode("arg", attrs = c(default = "TRUE"),newXMLNode("name", "foo"),newXMLNode("defaultValue", "1:10"))xmlAttrs(a) = c(a = 1, b = "a string")xmlAttrs(a) = c(a = 1, b = "a string", append = FALSE)newXMLNamespace(a, c("r" = "http://www.r-project.org"))xmlAttrs(a) = c("r:class" = "character")xmlAttrs(a[[1]]) = c("r:class" = "character")# Using a character vector as a namespace definitionsx = xmlNode("bob",namespaceDefinitions = c(r = "http://www.r-project.org",omg = "https://www.omegahat.net"))}\keyword{file}