Milan is correct. The prefix is used when saving the XML content that is represented in a different format in R.
To get the prefix <?xml version="1.0"?> on the XML content that you save, use a document object doc = newXMLDoc() root = newXMLNode("foo", doc = doc) saveXML(doc) <?xml version="1.0"?> <foo/> Sorry for the confusion. D On 10/17/13 2:36 AM, Milan Bouchet-Valat wrote: > 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@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. > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.