1\name{asXMLTreeNode}
2\alias{asXMLTreeNode}
3\title{Convert a regular XML node to one for use in a "flat" tree}
4\description{
5 This coerces a regular R-based XML node (i.e. not an internal C-level
6 node) to a form that can be inserted into a flat tree, i.e.
7 one that stores the nodes in a non-hierarchical manner.
8 It is thus used in conjunction with
9 \code{\link{xmlHashTree}}
10%% and \code{\link{xmlFlatListTree}}.
11 It adds \code{id} and \code{env} fields to the
12 node and specializes the class by prefixing \code{className}
13 to the class attribute.
14
15 This is not used very much anymore as we use the internal nodes for
16 most purposes.
17}
18\usage{
19asXMLTreeNode(node, env, id = get(".nodeIdGenerator", env)(xmlName(node)),
20              className = "XMLTreeNode")
21}
22%- maybe also 'usage' for other objects documented here.
23\arguments{
24  \item{node}{the original XML node}
25  \item{env}{the \code{XMLFlatTree} object into which this node will be inserted.}
26  \item{id}{the identifier for the node in the flat tree. If this is not
27    specified, we consult the tree itself and its built-in identifier
28    generator.  By default, the name of the node is used as its
29    identifier unless there is another node with that name.
30  }
31  \item{className}{a vector of class names to be prefixed to the
32    existing class vector of the node.}
33
34}
35\value{
36  An object of class \code{className}, i.e. by default
37  \code{"XMLTreeNode"}.
38}
39\references{\url{http://www.w3.org/XML}}
40\author{ Duncan Temple Lang }
41
42\seealso{
43  \code{\link{xmlHashTree}}
44%%  \code{\link{xmlFlatListTree}}
45}
46\examples{
47  txt = '<foo a="123" b="an attribute"><bar>some text</bar>other text</foo>'
48  doc = xmlTreeParse(txt)
49
50  class(xmlRoot(doc))
51
52  as(xmlRoot(doc), "XMLInternalNode")
53}
54\keyword{IO}
55\concept{XML}
56