Learn R Programming

XML (version 3.99-0.17)

xmlToS4: General mechanism for mapping an XML node to an S4 object

Description

This generic function and its methods recursively process an XML node and its child nodes ( and theirs and so on) to map the nodes to S4 objects.

This is the run-time function that corresponds to the makeClassTemplate function.

Usage

xmlToS4(node, obj = new(xmlName(node)), ...)

Value

The object obj whose slots have been modified.

Arguments

node

the top-level XML node to convert to an S4 object

obj

the object whose slots are to be filled from the information in the XML node

...

additional parameters for methods

Author

Duncan Temple Lang

See Also

makeClassTemplate

Examples

Run this code
 txt = paste0("ABCXYZ',
              3.54available")
 doc = xmlParse(txt)

 setClass("part", representation(name = "character",
                                 type = "character",
                                 cost = "numeric",
                                 status= "character"))
 xmlToS4(xmlRoot(doc)[["part"]])

Run the code above in your browser using DataLab