XML::Parser::Style::EasyTree - Parse xml to simple tree
Version 0.02
use XML::Parser; my $p = XML::Parser->new( Style => 'EasyTree' );
<root> </root>
will be
# ...
Allow to set prefix for name of attribute nodes;
<item attr="value" /> # will be item => { -attr => 'value' }; # with $TEXT{ATTR} = '+'; # will be item => { '+attr' => 'value' };
Allow to set name for text nodes
<item><sub attr="t"></sub>Text value</item> # will be item => { sub => { -attr => "t" }, #text => 'Text value' }; # with $TEXT{NODE} = ''; # will be item => { sub => { -attr => "t" }, '' => 'Text value' };
Allow to set join separator for text node, splitted by subnodes
<item>Test1<sub />Test2</item> # will be item => { sub => '', #text => 'Test1Test2' }; # with $TEXT{JOIN} = '+'; # will be item => { sub => '', #text => 'Test1+Test2' };
Allow to force nodes to be represented always as arrays. If name is empty string, then ot means ALL
<item><sub attr="t"></sub>Text value</item> # will be item => { sub => { -attr => "t" }, #text => 'Text value' }; # with $FORCE_ARRAY{sub} = 1; # will be item => { sub => [ { -attr => "t" } ], #text => 'Text value' }; # with $FORCE_ARRAY{''} = 1; # will be item => [ { sub => [ { -attr => "t" } ], #text => 'Text value' } ];
Allow to force text-only nodes to be represented always as hashes. If name is empty string, then ot means ALL
<item><sub>Text value</sub><any>Text value</any></item> # will be item => { sub => 'Text value', any => 'Text value' }; # with $FORCE_HASH{sub} = 1; # will be item => { sub => { #text => 'Text value' }, any => 'Text value' }; # with $FORCE_HASH{''} = 1; # will be item => { sub => { #text => 'Text value' }, any => { #text => 'Text value' } };
Allow to strip something from tag names by regular expressions
<a:item><b:sub>Text value</b:sub></a:item> # will be 'a:item' => { 'b:sub' => 'Text value' }; # with @STRIP_KEY = (qr/^[^:]+:/); # will be 'item' => { 'sub' => 'Text value' };
Mons Anderson, <mons at cpan.org>
None known
Copyright 2009 Mons Anderson
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install XML::Parser::Style::EasyTree, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Parser::Style::EasyTree
CPAN shell
perl -MCPAN -e shell install XML::Parser::Style::EasyTree
For more information on module installation, please visit the detailed CPAN module installation guide.