as.xml: Represent an Object as XML

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

as.xml is generic, with a default method and methods for character and data.frame. The intent is to convert text-like objects to informal XML that can be navigated with XPath expressions, e.g. using package XML.

Usage

1
2
3
4
5
6
## Default S3 method:
as.xml(x, tag, ...)
## S3 method for class 'character'
as.xml(x, tag, ...)
## S3 method for class 'data.frame'
as.xml(x,keyname='row',key=rownames(x),...)

Arguments

x

an object to convert

tag

an XML element name for open and close tags in which to enclose members of x; can be a vector

keyname

an XML element name to hold each value of each column in x

key

a vector of unique identifiers to distinguish each value of each column in x

...

name/value pairs to construct attributes in the ‘open’ tags (ignored for the data.frame method)

Details

The default method simply coerces its argument to character.

The character method pastes tag as an XML element name (in brackets) before and after x. Dots are used to construct attributes. Like tag itself, the attributes can be vectors; in both cases the usual recycling rules apply, as for paste.

The data.frame method calls the character method on each of its columns, passing keyname and keys as tag and key, respectively. keys should generally be unique. Note that the columns have no parent: supply one manually with nest, if necessary.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

1
nest(as.xml(head(Theoph)),tag='frame')

anniejw6/metrumrg documentation built on May 10, 2019, 11:50 a.m.