GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  XML::PARSER::STYLE::ETREE (3)

.ds Aq ’

NAME

XML::Parser::Style::ETree - Parse xml to simple tree

CONTENTS

VERSION

Version 0.09

SYNOPSIS



        use XML::Parser;
        my $p = XML::Parser->new( Style => ETree );



EXAMPLE



        <root at="key">
                <nest>
                        first
                        <v>a</v>
                        mid
                        <v at="a">b</v>
                        <vv></vv>
                        last
                </nest>
        </root>



will be



        {
                root => {
                        -at => key,
                        nest => {
                                #text => firstmidlast,
                                vv => ,
                                v => [
                                        a,
                                        {
                                                -at => a,
                                                #text => b
                                        }
                                ]
                        }
                }
        }



SPECIAL VARIABLES

$TEXT{ATTR} [ = ’-’ ] 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 };



$TEXT{NODE} [ = ’#text’ ] 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 };



$TEXT{JOIN} [ = ’’ ] 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 };



$TEXT{TRIM} [ = 1 ] Trim leading and trailing whitespace from text nodes



        <item>  Test1  <sub />  Test2  </item>
        # will be
        item => { sub => , #text => Test1Test2 };

        # with
        $TEXT{TRIM} = 0;
        # will be
        item => { sub => , #text =>   Test1    Test2   };



%FORCE_ARRAY 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 } ];



%FORCE_HASH 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 } };



@STRIP_KEY 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 };



SEE ALSO

o XML::Parser

The parser itself

o XML::Parser::EasyTree

Another EasyTree (I didn’t found it before my first commit of this package because of missing ’::Style’ in it’s name)

But since XML::Parser::EasyTree and XML::Parser::Style::EasyTree use same style name, they’re mutual exclusive ;(

So, all the functionality was moved to ETree, and EasyTree was kept as a compatibility wrapper

o XML::Bare

Very-very fast XML parser. Recommend to look

o XML::Hash::LX

Similar behaviour, same output, but using XML::LibXML

AUTHOR

Mons Anderson, <mons at cpan.org>

BUGS

None known

COPYRIGHT & LICENSE

Copyright 2009 Mons Anderson

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 XML::PARSER::STYLE::ETREE (3) 2009-08-27

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.