x <- read_xml('
')
xml_ns(x)
# When there are default namespaces, it's a good idea to rename
# them to give informative names:
ns <- xml_ns_rename(xml_ns(x), d1 = "foo", d2 = "bar")
ns
# Now we can pass ns to other xml function to use fully qualified names
baz <- xml_children(xml_children(x))
xml_name(baz)
xml_name(baz, ns)
xml_find_all(x, "//baz")
xml_find_all(x, "//foo:baz", ns)
str(as_list(x))
str(as_list(x, ns))
Run the code above in your browser using DataLab