File: asXMLTreeNode.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 (55 lines) | stat: -rw-r--r-- 1,776 bytes parent folder | download | duplicates (2)
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
48
49
50
51
52
53
54
55
\name{asXMLTreeNode}
\alias{asXMLTreeNode}
\title{Convert a regular XML node to one for use in a "flat" tree}
\description{
 This coerces a regular R-based XML node (i.e. not an internal C-level
 node) to a form that can be inserted into a flat tree, i.e.
 one that stores the nodes in a non-hierarchical manner.
 It is thus used in conjunction with
 \code{\link{xmlHashTree}}
%% and \code{\link{xmlFlatListTree}}.
 It adds \code{id} and \code{env} fields to the
 node and specializes the class by prefixing \code{className}
 to the class attribute.

 This is not used very much anymore as we use the internal nodes for
 most purposes.
}
\usage{
asXMLTreeNode(node, env, id = get(".nodeIdGenerator", env)(xmlName(node)),
              className = "XMLTreeNode")
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{node}{the original XML node}
  \item{env}{the \code{XMLFlatTree} object into which this node will be inserted.}
  \item{id}{the identifier for the node in the flat tree. If this is not
    specified, we consult the tree itself and its built-in identifier
    generator.  By default, the name of the node is used as its
    identifier unless there is another node with that name.
  }
  \item{className}{a vector of class names to be prefixed to the
    existing class vector of the node.}

}
\value{
  An object of class \code{className}, i.e. by default
  \code{"XMLTreeNode"}.
}
\references{\url{https://www.w3.org/XML/}}
\author{ Duncan Temple Lang }

\seealso{
  \code{\link{xmlHashTree}}
%%  \code{\link{xmlFlatListTree}}  
}
\examples{
  txt = '<foo a="123" b="an attribute"><bar>some text</bar>other text</foo>'
  doc = xmlTreeParse(txt)

  class(xmlRoot(doc))

  as(xmlRoot(doc), "XMLInternalNode")
}
\keyword{IO}
\concept{XML}