File: as_list.Rd

package info (click to toggle)
r-cran-xml2 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 976 kB
  • sloc: cpp: 1,826; xml: 333; javascript: 238; ansic: 178; sh: 71; makefile: 6
file content (46 lines) | stat: -rw-r--r-- 1,837 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
% 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]{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 attributes). Default namespaces must be given an explicit
name. The ns is ignored when using \code{\link[=xml_name<-]{xml_name<-()}} and
\code{\link[=xml_set_name]{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]{class()}}, \code{\link[=comment]{comment()}}, \code{\link[=dim]{dim()}},
\code{\link[=dimnames]{dimnames()}}, \code{\link[=names]{names()}}, \code{\link[=row.names]{row.names()}} and
\code{\link[=tsp]{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>"))
}