xmlRead.default: General import function to reads XML data of different types

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

View source: R/utils.xmlRead.R

Description

This function controls the import of input data set.

Usage

1
xmlRead.default(xmlItem)

Arguments

xmlItem

(XMLNode) Object of class XMLNode that defines the a list object and fullfills XSD definition 'xmlReadData_list'.

Details

Based on the tag name of the input data definition in the XML file, the corresponding readXMLData_* function is called, whereby * is a placeholder for the data type definition in the XML scheme. For example, for XML definitions following the data.frame specification, a function readXMLData_data.frame <- function(xmlDataItem) is expected, which implements the XML parser for data.frames and returns the data as R object.

Value

(data.frame) or (variable) or (vector) or a named list of all imported input datasets.

Author(s)

Matthias Pfeifer matthias.pfeifer@roche.com

See Also

XMLNode-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data <- '<text type="character">My text is awesome</text>'
item <- XML::xmlRoot(XML::xmlParse(data,asText=TRUE))
value <- RTest::xmlRead.default(item)
stopifnot(value=="My text is awesome")

data <- '<list><data.frame><col-defs>
<coldef name="Column1" type="character"/>
<coldef name="Column2" type="numeric"/>
</col-defs>
<row name="1"><cell>ID1</cell><cell>1</cell></row>
<row name="2"><cell>ID2</cell><cell>2.1</cell></row>
<row name="3"><cell>ID3</cell><cell>3.1</cell></row>
</data.frame></list>'
item <- XML::xmlRoot(XML::xmlParse(data,asText=TRUE))
value <- RTest::xmlRead.default(item)
stopifnot(dim(value)[1]==3)
stopifnot(dim(value)[2]==2)

data <- '<variable type="character" value="My text is awesome"/>'
item <- XML::xmlRoot(XML::xmlParse(data,asText=TRUE))
value <- RTest::xmlRead.default(item)
stopifnot(value=="My text is awesome")

RTest documentation built on Dec. 4, 2019, 5:07 p.m.