Abstract
In this chapter, we explore approaches to creating XML content within R. The primary approach is to create nodes and trees that are identical in nature to those returned by the XML parser via the xmlParse() and htmlParse() functions. Rather than generating an entire document in one step, we use functions to build individual nodes, add child nodes and attributes, and set namespaces. We discuss different approaches to building these trees—from top down or bottom up, or a hybrid of both approaches. In some circumstances, where the subtree is large and the nodes have a very regular structure, we can create the XML content more speedily via vectorized string manipulation and then parsing the content into a subtree, thus combining a string-based approach with operating on nodes and trees.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Elliotte Rusty Harold andW. Scott Means. XML in a Nutshell. O’Reilly Media, Inc., Sebastopol, CA, 2004.
David Hunter, Jeff Rafter, Joe Fawcett, Eric van der Vlist, Danny Ayers, Jon Duckett, Andrew Watt, and Linda McKinnon. Beginning XML. Wiley Publishing, Inc., Indianapolis, IN, fourth edition, 2007.
Eric Lecoutre. R2HTML: HTML exportation for R objects. http://cran.r-project.org/package=R2HTML, 2011. R package version 2.2.
Deborah Nolan and Duncan Temple Lang. RKML: Simple tools for creating KML displays from R. http://www.omegahat.org/RKML/, 2011. R package version 0.7.
Duncan Temple Lang. XML: Tools for parsing and generating XML within R and S-PLUS. http://www.omegahat.org/RSXML, 2011. R package version 3.4.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2014 Springer Science+Business Media New York
About this chapter
Cite this chapter
Nolan, D., Lang, D.T. (2014). Generating XML . In: XML and Web Technologies for Data Sciences with R. Use R!. Springer, New York, NY. https://doi.org/10.1007/978-1-4614-7900-0_6
Download citation
DOI: https://doi.org/10.1007/978-1-4614-7900-0_6
Published:
Publisher Name: Springer, New York, NY
Print ISBN: 978-1-4614-7899-7
Online ISBN: 978-1-4614-7900-0
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)