xml_ns_strip: Strip the default namespaces from a document

Description Usage Arguments Examples

View source: R/xml_modify.R

Description

Strip the default namespaces from a document

Usage

1

Arguments

x

A document, node, or node set.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- read_xml(
 "<foo xmlns = 'http://foo.com'>
   <baz/>
   <bar xmlns = 'http://bar.com'>
     <baz/>
   </bar>
  </foo>")
# Need to specify the default namespaces to find the baz nodes
xml_find_all(x, "//d1:baz")
xml_find_all(x, "//d2:baz")

# After stripping the default namespaces you can find both baz nodes directly
xml_ns_strip(x)
xml_find_all(x, "//baz")

xml2 documentation built on Jan. 24, 2018, 5:21 p.m.