Applies a function to each of the children of an XMLNode
xmlApply.RdThese methods are simple wrappers for the
lapply and sapply functions.
They operate on the
sub-nodes of the XML node, and not on the fields of the node object itself.
Usage
xmlApply(X, FUN, ...)
# S3 method for class 'XMLNode'
xmlApply(X, FUN, ...)
# S3 method for class 'XMLDocument'
xmlApply(X, FUN, ...)
# S3 method for class 'XMLDocumentContent'
xmlApply(X, FUN, ...)
xmlSApply(X, FUN, ...)
# S3 method for class 'XMLNode'
xmlSApply(X, FUN, ...)
# S3 method for class 'XMLDocument'
xmlSApply(X, FUN, ...)Arguments
- X
the
XMLNodeon whose children the regularapplyorsapplyis to be performed- FUN
the function to apply to each child node. This is passed directly to the relevant
applyfunction.- ...
additional arguments to be given to each invocation of
FUN. This is passed directly to the relevantapplyfunction.
Examples
doc <- xmlTreeParse(system.file("exampleData", "mtcars.xml", package="XML"))
r <- xmlRoot(doc)
xmlSApply(r[[2]], xmlName)
#> text
#> "text"
xmlApply(r[[2]], xmlAttrs)
#> $text
#> NULL
#>
xmlSApply(r[[2]], xmlSize)
#> text
#> 0