.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "EasyTree 3pm" .TH EasyTree 3pm "2021-12-23" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XML::Parser::EasyTree \- Easier tree style for XML::Parser .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& use XML::Parser; \& use XML::Parser::EasyTree; \& $XML::Parser::Easytree::Noempty=1; \& my $p=new XML::Parser(Style=>\*(AqEasyTree\*(Aq); \& my $tree=$p\->parsefile(\*(Aqsomething.xml\*(Aq); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" XML::Parser::EasyTree adds a new \*(L"built-in\*(R" style called \*(L"EasyTree\*(R" to XML::Parser. Like XML::Parser's \*(L"Tree\*(R" style, setting this style causes the parser to build a lightweight tree structure representing the \s-1XML\s0 document. This structure is, at least in this author's opinion, easier to work with than the one created by the built-in style. .PP When the parser is invoked with the EasyTree style, it returns a reference to an array of tree nodes, each of which is a hash reference. All nodes have a 'type' key whose value is the type of the node: 'e' for element nodes, 't' for text nodes, and 'p' for processing instruction nodes. All nodes also have a 'content' key whose value is a reference to an array holding the element's child nodes for element nodes, the string value for text nodes, and the data value for processing instruction nodes. Element nodes also have an 'attrib' key whose value is a reference to a hash of attribute names and values. Processing instructions also have a 'target' key whose value is the \s-1PI\s0's target. .PP EasyTree nodes are ordinary Perl hashes and are not objects. Contiguous runs of text are always returned in a single node. .PP The reason the parser returns an array reference rather than the root element's node is that an \s-1XML\s0 document can legally contain processing instructions outside the root element (the xml-stylesheet \s-1PI\s0 is commonly used this way). .PP If the parser's Namespaces option is set, element and attribute names will be prefixed with their (possibly empty) namespace \s-1URI\s0 enclosed in curly brackets. .SH "SPECIAL VARIABLES" .IX Header "SPECIAL VARIABLES" Two package global variables control special behaviors: .IP "XML::Parser::EasyTree::Latin" 4 .IX Item "XML::Parser::EasyTree::Latin" If this is set to a nonzero value, all text, names, and values will be returned in \s-1ISO\-8859\-1\s0 (Latin\-1) encoding rather than \s-1UTF\-8.\s0 .IP "XML::Parser::EasyTree::Noempty" 4 .IX Item "XML::Parser::EasyTree::Noempty" If this is set to a nonzero value, text nodes containing nothing but whitespace (such as those generated by line breaks and indentation between tags) will be omitted from the parse tree. .SH "EXAMPLE" .IX Header "EXAMPLE" Parse a prettyprined version of the \s-1XML\s0 shown in the example for the built-in \*(L"Tree\*(R" style: .PP .Vb 5 \& #!perl \-w \& use strict; \& use XML::Parser; \& use XML::Parser::EasyTree; \& use Data::Dumper; \& \& $XML::Parser::EasyTree::Noempty=1; \& my $xml=<<\*(AqEOF\*(Aq; \& \& Hello there \& \& Howdy \& \& do \& \& EOF \& my $p=new XML::Parser(Style=>\*(AqEasyTree\*(Aq); \& my $tree=$p\->parse($xml); \& print Dumper($tree); .Ve .PP Returns: .PP .Vb 10 \& $VAR1 = [ \& { \*(Aqname\*(Aq => \*(Aqfoo\*(Aq, \& \*(Aqtype\*(Aq => \*(Aqe\*(Aq, \& \*(Aqcontent\*(Aq => [ \& { \*(Aqname\*(Aq => \*(Aqhead\*(Aq, \& \*(Aqtype\*(Aq => \*(Aqe\*(Aq, \& \*(Aqcontent\*(Aq => [ \& { \*(Aqtype\*(Aq => \*(Aqt\*(Aq, \& \*(Aqcontent\*(Aq => \*(AqHello \*(Aq \& }, \& { \*(Aqname\*(Aq => \*(Aqem\*(Aq, \& \*(Aqtype\*(Aq => \*(Aqe\*(Aq, \& \*(Aqcontent\*(Aq => [ \& { \*(Aqtype\*(Aq => \*(Aqt\*(Aq, \& \*(Aqcontent\*(Aq => \*(Aqthere\*(Aq \& } \& ], \& \*(Aqattrib\*(Aq => {} \& } \& ], \& \*(Aqattrib\*(Aq => { \*(Aqid\*(Aq => \*(Aqa\*(Aq \& } \& }, \& { \*(Aqname\*(Aq => \*(Aqbar\*(Aq, \& \*(Aqtype\*(Aq => \*(Aqe\*(Aq, \& \*(Aqcontent\*(Aq => [ \& { \*(Aqtype\*(Aq => \*(Aqt\*(Aq, \& \*(Aqcontent\*(Aq => \*(AqHowdy\*(Aq \& }, \& { \*(Aqname\*(Aq => \*(Aqref\*(Aq, \& \*(Aqtype\*(Aq => \*(Aqe\*(Aq, \& \*(Aqcontent\*(Aq => [], \& \*(Aqattrib\*(Aq => {} \& } \& ], \& \*(Aqattrib\*(Aq => {} \& }, \& { \*(Aqtype\*(Aq => \*(Aqt\*(Aq, \& \*(Aqcontent\*(Aq => \*(Aq \& do \& \*(Aq \& } \& ], \& \*(Aqattrib\*(Aq => {} \& } \& ]; .Ve .SH "AUTHOR" .IX Header "AUTHOR" Eric Bohlman (ebohlman@omsdev.com) .PP Copyright (c) 2001 Eric Bohlman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" .Vb 1 \& XML::Parser .Ve