File: xmlToS4.Rd

package info (click to toggle)
r-cran-xml 3.99-0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,688 kB
  • sloc: ansic: 6,659; xml: 2,890; asm: 486; sh: 12; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,358 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
\name{xmlToS4}
\alias{xmlToS4}
\alias{xmlToS4,XMLInternalNode-method}

\title{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
  \code{\link{makeClassTemplate}} function.
}
\usage{
xmlToS4(node, obj = new(xmlName(node)), ...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{node}{the top-level XML node to convert to an S4 object}
  \item{obj}{the object whose slots are to be filled from the
  information in the XML node}
  \item{\dots}{additional parameters for methods}
}
\value{
 The object \code{obj} whose slots have been modified.
}

\author{Duncan Temple Lang}

\seealso{
 \code{\link{makeClassTemplate}}  
}
\examples{
 txt = paste0("<doc><part><name>ABC</name><type>XYZ</type>',
              <cost>3.54</cost><status>available</status></part></doc>")
 doc = xmlParse(txt)

 setClass("part", representation(name = "character",
                                 type = "character",
                                 cost = "numeric",
                                 status= "character"))
 xmlToS4(xmlRoot(doc)[["part"]])
}
\keyword{programming}
\keyword{IO}
\concept{meta-computing}