man-pages/man3/XML::Parser::Style::Tree.3pm.html
2021-03-31 01:06:50 +01:00

93 lines
2.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Parser::Style::Tree</TITLE>
</HEAD><BODY>
<H1>Parser::Style::Tree</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-10-03<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
XML::Parser::Style::Tree - Tree style parser
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
use XML::Parser;
my $p = XML::Parser-&gt;new(Style =&gt; 'Tree');
my $tree = $p-&gt;parsefile('foo.xml');
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
This module implements XML::Parser's Tree style parser.
<P>
When parsing a document, <TT>&quot;parse()&quot;</TT> will return a parse tree for the
document. Each node in the tree
takes the form of a tag, content pair. Text nodes are represented with
a pseudo-tag of ``0'' and the string that is their content. For elements,
the content is an array reference. The first item in the array is a
(possibly empty) hash reference containing attributes. The remainder of
the array is a sequence of tag-content pairs representing the content
of the element.
<P>
So for example the result of parsing:
<P>
<PRE>
&lt;foo&gt;&lt;head id=&quot;a&quot;&gt;Hello &lt;em&gt;there&lt;/em&gt;&lt;/head&gt;&lt;bar&gt;Howdy&lt;ref/&gt;&lt;/bar&gt;do&lt;/foo&gt;
</PRE>
<P>
would be:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tag&nbsp;&nbsp;&nbsp;Content
<BR>&nbsp;&nbsp;==================================================================
<BR>&nbsp;&nbsp;[foo,&nbsp;[{},&nbsp;head,&nbsp;[{id&nbsp;=&gt;&nbsp;``a''},&nbsp;0,&nbsp;``Hello&nbsp;'',&nbsp;&nbsp;em,&nbsp;[{},&nbsp;0,&nbsp;``there'']],
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bar,&nbsp;[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{},&nbsp;0,&nbsp;``Howdy'',&nbsp;&nbsp;ref,&nbsp;[{}]],
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,&nbsp;``do''
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]
<BR>&nbsp;&nbsp;]
<P>
The root document ``foo'', has 3 children: a ``head'' element, a ``bar''
element and the text ``do''. After the empty attribute hash, these are
represented in it's contents by 3 tag-content pairs.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:06:01 GMT, March 31, 2021
</BODY>
</HTML>