NAME

XML::Bare::SAX::Parser

SYNOPSIS

use XML::Simple;
use Data::Dumper;

$XML::Simple::PREFERRED_PARSER = 'XML::Bare::SAX::Parser';

my $ref = XMLin("<xml><namea blah=1>bob</namea><nameb>testsfs</nameb></xml>");

print Dumper( $ref );

DESCRIPTION

This module uses the 'Bare XML' parser from XML::Bare to generate Perl SAX calls. The parser itself is minimalistic and is a simle state engine written in ~500 lines of C.

Supported XML

The XML parser used in the module can parse standard XML cleanly. Note that is very accepting in its parsing and will continue parsing regardless of whether the XML you feed it is valid or not.

Parsing Limitations / Features

  • XML Parser demands a properly structured XML document

    XML Parsing will generate rubbish if you feed it XML that does not have ending tags for each of the opening tags contained in the document. The structure of the passed XML text must be clean in order for the parser to work properly.

  • Mixed XML is not supported

    Mixed XML -will- parse, but it will not generate SAX calls for the mixed content. The mixed content will be ignored.

  • Extended xml node types are discarded

    Doctype is ignored, comments are ignored, PI sections are ignored.

  • CDATA sections are parsed properly

Module Functions

  • $ob = new XML::Bare::SAX::Parser( ... )

    Basic constructor; used behind the scenes by the calling SAX Listener.

Functions Used Internally

  • $ob->parse()

  • $ob->free_tree()

Performance

In comparison to other SAX parsers, XML::Bare::SAX::Parser is extremely fast. It runs nearly 10 times faser than the other Perl SAX Parsers available. It does so by only generating calls for a basic set of XML features.

See XML::Bare POD for some example benchmarks of XML::Simple run with this parser in comparison to other tree parsers including XML::Bare.

Apologetics

The feature set of the parser make it optimal for use with XML::Simple.

If you like the parser in XML::Bare but prefer using XML::Simple and the structure it generates then this module is for you.

Note that the author of XML::Simple has expressed fairly strong dissaproval of the lax parsing of XML::Bare and probably would not reccomend using his module in combination with XML::Bare::SAX::Parser. That said, it is a free country, and all mentioned modules are open source. Hurray for the freedom to choose and the ability to get more speed out of the the modules you like.

If you like this module, please reccomend it to others. If you have problems with it, please let me know what issues you have and I will attempt to resolve them.

If you have gripes about the module not parsing according to the official XML specifications, you should switch to using a different SAX parser.

LICENSE

Copyright (C) 2007 David Helkowski

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.  You may also can
redistribute it and/or modify it under the terms of the Perl
Artistic License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.