Tree::Simple::SAX - A set of classes for using Tree::Simple with XML
use Tree::Simple::SAX; use XML::SAX::ParserFactory; my $handler = Tree::Simple::SAX::Handler->new(Tree::Simple->new()); my $p = XML::SAX::ParserFactory->parser(Handler => $handler); $p->parse_string('<xml><string>Hello <world/>!</string></xml>'); # this will create a tree like this: # { tag_type => 'xml' } # { tag_type => 'string' } # { content => 'Hello ', tag_type => 'CDATA' } # { tag_type => 'world' } # { content => '!', tag_type => 'CDATA' }
This is an early implementation of an XML::SAX handler which creates a Tree::Simple object hierarchy from the XML stream. It is currently in the proof-of-concept/experimental stages and I plan to add more features in the future.
If anyone else is interested in the development of this module, feel free to contact me (use the email in the AUTHOR section). I am always open to discussion, thoughts, criticism and especially patches :)
This is in no way an attempt to make an alternate to the XML DOM, or to provide Yet Another XML Tree module. My intent is to create a tool for easy reading and writing of Tree::Simple object hierarchies in an XML format. My focus is on making XML work for Tree::Simple rather than making Tree::Simple work for XML.
Add an XML::SAX driver which can create an XML string from an existing Tree::Simple heirarchy.
I only support the basic start_element, end_element and character.
start_element
end_element
character
None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it.
I use Devel::Cover to test the code coverage of my tests, below is the Devel::Cover report on this module test suite.
---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt branch cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ Tree/Simple/SAX.pm 100.0 n/a n/a 100.0 n/a 13.3 100.0 Tree/Simple/SAX/Handler.pm 100.0 100.0 41.7 100.0 100.0 86.7 89.9 ---------------------------- ------ ------ ------ ------ ------ ------ ------ Total 100.0 100.0 41.7 100.0 100.0 100.0 91.4 ---------------------------- ------ ------ ------ ------ ------ ------ ------
stevan little, <stevan@iinteractive.com>
Copyright 2004 by Infinity Interactive, Inc.
http://www.iinteractive.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tree::Simple::SAX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tree::Simple::SAX
CPAN shell
perl -MCPAN -e shell install Tree::Simple::SAX
For more information on module installation, please visit the detailed CPAN module installation guide.