Navigate around the family tree.
xml_children
returns only elements, xml_contents
returns
all nodes. xml_length
returns the number of children.
xml_parent
returns the parent node, xml_parents
returns all parents up to the root. xml_siblings
returns all nodes
at the same level. xml_child
makes it easy to specify a specific
child to return.
xml_children(x) xml_child(x, search = 1, ns = xml_ns(x)) xml_contents(x) xml_parents(x) xml_siblings(x) xml_parent(x) xml_length(x, only_elements = TRUE) xml_root(x)
x |
A document, node, or node set. |
search |
For |
ns |
Optionally, a named vector giving prefix-url pairs, as produced
by |
only_elements |
For |
A node or nodeset (possibly empty). Results are always de-duplicated.
x <- read_xml("<foo> <bar><boo /></bar> <baz/> </foo>") xml_children(x) xml_children(xml_children(x)) xml_siblings(xml_children(x)[[1]]) # Note the each unique node only appears once in the output xml_parent(xml_children(x)) # Mixed content x <- read_xml("<foo> a <b/> c <d>e</d> f</foo>") # Childen gets the elements, contents gets all node types xml_children(x) xml_contents(x) xml_length(x) xml_length(x, only_elements = FALSE) # xml_child makes it easier to select specific children xml_child(x) xml_child(x, 2) xml_child(x, "baz")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.