-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathas_list.Rd
46 lines (43 loc) · 1.71 KB
/
as_list.Rd
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/as_list.R
\name{as_list}
\alias{as_list}
\title{Coerce xml nodes to a list.}
\usage{
as_list(x, ns = character(), ...)
}
\arguments{
\item{x}{A document, node, or node set.}
\item{ns}{Optionally, a named vector giving prefix-url pairs, as produced
by \code{\link{xml_ns}}. If provided, all names will be explicitly
qualified with the ns prefix, i.e. if the element \code{bar} is defined
in namespace \code{foo}, it will be called \code{foo:bar}. (And
similarly for atttributes). Default namespaces must be given an explicit
name. The ns is ignored when using \code{\link{xml_name<-}} and
\code{\link{xml_set_name}}.}
\item{...}{Needed for compatibility with generic. Unused.}
}
\description{
This turns an XML document (or node or nodeset) into the equivalent R
list. Note that this is \code{as_list()}, not \code{as.list()}:
\code{lapply()} automatically calls \code{as.list()} on its inputs, so
we can't override the default.
}
\details{
\code{as_list} currently only handles the four most common types of
children that an element might have:
\itemize{
\item Other elements, converted to lists.
\item Attributes, stored as R attributes. Attributes that have special meanings in R
(\code{\link{class}}, \code{\link{comment}}, \code{\link{dim}},
\code{\link{dimnames}}, \code{\link{names}}, \code{\link{row.names}} and
\code{\link{tsp}}) are escaped with '.'
\item Text, stored as a character vector.
}
}
\examples{
as_list(read_xml("<foo> a <b /><c><![CDATA[<d></d>]]></c></foo>"))
as_list(read_xml("<foo> <bar><baz /></bar> </foo>"))
as_list(read_xml("<foo id = 'a'></foo>"))
as_list(read_xml("<foo><bar id='a'/><bar id='b'/></foo>"))
}