XML : Setting default namespaces in an XMLTree in R

I am just getting started with R and am building an XML document with the XML package. For this, I'm trying to set default namespaces on certain nodes (as those are required for a certain template I'm trying to construct), but I can't figure out how. Setting namespaces with identifieres is easy enough, but even after digging through the XML documentation, the implementation of default namespaces escapes me. In several spots, the documentation suggests using empty names ("") for the namespace identifieres in the appropriate character vectors/lists, but that doesn't seem to be something R is even allowing?
A very simple sample XMLTree structure is below, but the goal is to set the two namespaces as default instead:

  require(XML)    xtree <- xmlTree()  xtree$addNode('First', attrs = c(version = '0.4'), close=FALSE, namespace = c('shouldBeDefault1' = 'http://www.foo.bar/data'))  xtree$addNode('Second', '', namespace = c('shouldBeDefault2' = 'http://www.foo.bar/data/b'))  xtree$closeTag()    xtree <- saveXML(xtree, file=NULL, compression=0, indent=TRUE, prefix = '<?xml version="1.0" encoding="UTF-8"?>', doctype = NULL,                  encoding = getEncoding(xtree))    

No comments:

Post a Comment