1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
\name{append.xmlNode}
\alias{append.xmlNode}
\alias{append.XMLNode}
\title{Add children to an XML node}
\description{
This appends one or more XML nodes as children of an existing node.
}
\usage{
append.XMLNode(to, ...)
append.xmlNode(to, ...)
}
\arguments{
\item{to}{the XML node to which the sub-nodes are to be added.}
\item{\dots}{the sub-nodes which are to be added to the \code{to} node.
If this is a \code{list} of \code{XMLNode} objects (e.g. create by a call to
\code{\link{lapply}}), then that list is used.}
}
\details{
\code{append.xmlNode} is a generic function with method \code{append.XMLNode}
for class \code{"XMLNode"} and default method \code{base::append}.
This seems historical and users may as well use \code{append.XMLNode}
directly.
}
\value{
The original \code{to} node containing its new children nodes.
}
\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{[<-.XMLNode}}
\code{\link{[[<-.XMLNode}}
\code{\link{[.XMLNode}}
\code{\link{[[.XMLNode}}
}
\examples{
# Create a very simple representation of a simple dataset.
# This is just an example. The result is
# <data numVars="2" numRecords="3">
# <varNames>
# <string>
# A
# </string>
# <string>
# B
# </string>
# </varNames>
# <record>
# 1.2 3.5
# </record>
# <record>
# 20.2 13.9
# </record>
# <record>
# 10.1 5.67
# </record>
# </data>
n = xmlNode("data", attrs = c("numVars" = 2, numRecords = 3))
n = append.xmlNode(n, xmlNode("varNames", xmlNode("string", "A"), xmlNode("string", "B")))
n = append.xmlNode(n, xmlNode("record", "1.2 3.5"))
n = append.xmlNode(n, xmlNode("record", "20.2 13.9"))
n = append.xmlNode(n, xmlNode("record", "10.1 5.67"))
print(n)
\dontrun{
tmp <- lapply(references, function(i) {
if(!inherits(i, "XMLNode"))
i <- xmlNode("reference", i)
i
})
r <- xmlNode("references")
r[["references"]] <- append.xmlNode(r[["references"]], tmp)
}
}
\keyword{file}
\keyword{IO}
|