1XML::Parser::Lite::TreeU(s3e)r Contributed Perl DocumentaXtMiLo:n:Parser::Lite::Tree(3)
2
3
4

NAME

6       XML::Parser::Lite::Tree - Lightweight XML tree builder
7

SYNOPSIS

9         use XML::Parser::Lite::Tree;
10
11         my $tree_parser = XML::Parser::Lite::Tree::instance();
12         my $tree = $tree_parser->parse($xml_data);
13
14           OR
15
16         my $tree = XML::Parser::Lite::Tree::instance()->parse($xml_data);
17

DESCRIPTION

19       This is a singleton class for parsing XML into a tree structure. How
20       does this differ from other XML tree generators? By using
21       XML::Parser::Lite, which is a pure perl XML parser. Using this module
22       you can tree-ify simple XML without having to compile any C.
23
24       For example, the following XML:
25
26         <foo woo="yay"><bar a="b" c="d" />hoopla</foo>
27
28       Parses into the following tree:
29
30                 'children' => [
31                                 {
32                                   'children' => [
33                                                   {
34                                                     'children' => [],
35                                                     'attributes' => {
36                                                                       'a' => 'b',
37                                                                       'c' => 'd'
38                                                                     },
39                                                     'type' => 'element',
40                                                     'name' => 'bar'
41                                                   },
42                                                   {
43                                                     'content' => 'hoopla',
44                                                     'type' => 'text'
45                                                   }
46                                                 ],
47                                   'attributes' => {
48                                                     'woo' => 'yay'
49                                                   },
50                                   'type' => 'element',
51                                   'name' => 'foo'
52                                 }
53                               ],
54                 'type' => 'root'
55               };
56
57       Each node contains a "type" key, one of "root", "element" and "text".
58       "root" is the document root, and only contains an array ref "children".
59       "element" represents a normal tag, and contains an array ref
60       "children", a hash ref "attributes" and a string "name".  "text" nodes
61       contain only a "content" string.
62

METHODS

64       instance()
65           Returns an instance of the tree parser.
66
67       new( options... )
68           Creates a new parser. Valid options include "process_ns" to process
69           namespaces.
70
71       parse($xml)
72           Parses the xml in $xml and returns the tree as a hash ref.
73

AUTHOR

75       Copyright (C) 2004-2008, Cal Henderson, <cal@iamcal.com>
76

SEE ALSO

78       XML::Parser::Lite.
79
80
81
82perl v5.36.0                      2023-01-20        XML::Parser::Lite::Tree(3)
Impressum