[R] saveXML() prefix argument

Earl Brown ekbrown at k-state.edu
Thu Oct 17 05:45:11 CEST 2013


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?

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



More information about the R-help mailing list