
Last chance! 50% off unlimited learning
Sale ends in
This returns a list of the children or sub-elements of an XML node whose tag name matches the one specified by the user.
xmlElementsByTagName(el, name, recursive = FALSE)
A list containing those child nodes of el
whose
tag name matches that specified by the user.
the node whose matching children are to be retrieved.
a string giving the name of the tag to match in each of
el
's children.
a logical value. If this is FALSE
, the
default, only the direct child nodes are searched.
Alternatively, if this is TRUE
, all sub-nodes
at all levels are searched. In other words,
we find all descendants of the node el
and return a list with the nodes having the given name.
The relationship between the nodes in the resulting list
cannot be determined. This is a set of nodes. See the note.
Duncan Temple Lang
This does a simple matching of names and subsets the XML node's
children list.
If recursive
is TRUE
, then the function is applied
recursively to the children of the given node and so on.
xmlChildren
xmlTreeParse
if (FALSE) {
doc <- xmlTreeParse("https://www.omegahat.net/Scripts/Data/mtcars.xml")
xmlElementsByTagName(doc$children[[1]], "variable")
}
doc <- xmlTreeParse(system.file("exampleData", "mtcars.xml", package="XML"))
xmlElementsByTagName(xmlRoot(doc)[[1]], "variable")
Run the code above in your browser using DataLab