[R] saveXML() prefix argument

Milan Bouchet-Valat nalimilan at club.fr
Thu Oct 17 11:36:31 CEST 2013


Le mercredi 16 octobre 2013 à 23:45 -0400, Earl Brown a écrit :
> I'm using the "XML" package and specifically the saveXML() function but I can't get the "prefix" argument of saveXML() to work:
> 
> library("XML")
> concepts <- c("one", "two", "three")
> info <- c("info one", "info two", "info three")
> root <- newXMLNode("root")
> for (i in 1:length(concepts)) {
> 	cur.concept <- concepts[i]
> 	cur.info <- info[i]
> 	cur.tip <- newXMLNode("tip", attrs = c(id = i), parent = root)
> 	newXMLNode("h1", cur.concept, parent = cur.tip)
> 	newXMLNode("p", cur.info, parent = cur.tip)
> }
> 
> # None of the following output a prefix on the first line of the exported document
> saveXML(root)
> saveXML(root, file = "test.xml")
> saveXML(root, file = "test.xml", prefix = '<?xml version="1.0"?>\n')
> 
> Am I missing something obvious? Any ideas?
It looks like the function XML:::saveXML.XMLInternalNode() does not use
the 'prefix' parameter at all. So it won't be taken into account when
calling saveXML() on objects of class XMLInternalNode.

I think you should report this to Duncan Temple Lang, as this is
probably an oversight.


Regards


> Thanks in advance. Earl Brown
> 
> -----
> Earl K. Brown, PhD
> Assistant Professor of Spanish Linguistics
> Advisor, TEFL MA Program
> Department of Modern Languages
> Kansas State University
> www-personal.ksu.edu/~ekbrown
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list