xmlCleanNamespaces.RdThis is a convenience function that removes redundant repeated namespace definitions in an XML node. It removes namespace definitions in nodes where an ancestor node also has that definition. It does not remove unused namespace definitions.
This uses the NSCLEAN option for xmlParse
either the name of an XML documentor the XML content itself, or an already parsed document
options for the XML parser. NSCLEAN is added to this.
additional arguments passed to xmlParse
the name of a file to which to write the resulting XML
document, or an empty character vector or logical value FALSE
to avoid writing the new document.
If the new document is written to a file, the name of the file is returned. Otherwise, the new parsed XML document is returned.
libxml2 documentation http://xmlsoft.org/html/libxml-parser.html
f = system.file("exampleData", "redundantNS.xml", package = "XML")
doc = xmlParse(f)
print(doc)
#> <?xml version="1.0"?>
#> <doc xmlns:r="http://www.r-project.org">
#> <r:func xmlns:r="http://www.r-project.org" xmlns:omg="http://www.omegahat.net">plot</r:func>
#> </doc>
#>
newDoc = xmlCleanNamespaces(f, out = FALSE)