XML::Rules

Description

XML::Rules is a Perl module that can parse XML & process tags by rules starting from leaves. SYNOPSIS use XML::Rules; $xml = < < *END* < doc > < person > < fname >...< /fname > < lname >...< /lname > < email >...< /email > < address > < street >...< /street > < city >...< /city > < country >...< /country > < bogus >...< /bogus > < /address > < phones > < phone type="home" >123-456-7890< /phone > < phone type="office" >663-486-7890< /phone > < phone type="fax" >663-486-7000< /phone > < /phones > < /person > < person > < fname >...< /fname > < lname >...< /lname > < email >...< /email > < address > < street >...< /street > < city >...< /city > < country >...< /country > < bogus >...< /bogus > < /address > < phones > < phone type="office" >663-486-7891< /phone > < /phones > < /person > < /doc > *END* @rules = ( _default = > sub {$_[0] = > $_[1]- >{_content}}, # by default Im only interested in the content of the tag, not the attributes bogus = > undef, # lets ignore this tag and all inner ones as well address = > sub {address = > "$_[1]- >{street}, $_[1]- >{city} ($_[1]- >{country})"}, # merge the address into a single string phone = > sub {$_[1]- >{type} = > $_[1]- >{content}}, # lets use the "type" attribute as the key and the content as the value phones = > sub {delete $_[1]- >{_content}; %{$_[1]}}, # remove the text content and pass along the type = > content from the child nodes person = > sub { # lets print the values, all the data is readily available in the attributes print "$_[1]- >{lname}, $_[1]- >{fname} < $_[1]- >{email} >n"; print "Home phone: $_[1]- >{home}n" if $_[1]- >{home}; print "Office phone: $_[1]- >{office}n" if $_[1]- >{office}; print "Fax: $_[1]- >{fax}n" if $_[1]- >{fax}; print "$_[1]- >{address}nn"; return; # the < person > tag is processed, no need to remember what it contained }, ); $parser = XML::Rules- >new(rules = > @rules); $parser- >parse( $xml);.

Xmlrules - Process Tags - Perl Module - Parse Xml - Rules - Type - Content - Address - Print - Libraries - Programming

Published By:Jan Krynicky

License Type:Freeware

Date Added:25 October, 2010

Version:0.18

Price:Free

Downloads:77

Size:38.9 KB

Platform: Linux

What people say
- required fields
     
Related Downloads

Data::Encrypted is a Perl module to transparently store encrypted data via RSA. SYNOPSIS # functional interface: use Data::Encrypted file => "./.

DateAug 12, 2010

AuthorAaron J Mackey

Size7.2 KB

LicenseFreeware

PriceFree

PlatformLinux

CategoryLinux Programming

XML::Generator::vCard is a Perl module that can generate SAX2 events for vCard 3.

DateOct 4, 2010

AuthorAaron Straup Cope

Size7.2 KB

LicenseFreeware

PriceFree

PlatformLinux

CategoryLinux Programming

WWW::Webrobot::pod::Testplan is a Perl module that helps you on how to write a test plan for webrobot. A test plan is a list of elements. An element itself may be a request, a (sub) test plan, an include or a cookie control command.

DateAug 25, 2010

AuthorABAS Software AG

Size98.3 KB

LicenseFreeware

PriceFree

PlatformLinux

CategoryLinux Programming

Test::Stochastic is a Perl module to check probabilities of randomized methods. SYNOPSIS use Test::Stochastic qw(stochastic_ok); stochastic_ok sub { ...random sub...}, {a => 0.4, b => 0.6}; stochastic_ok {a => 0.4, b => 0.

DateAug 26, 2010

AuthorAbhijit Mahabal

Size4.1 KB

LicenseFreeware

PriceFree

PlatformLinux

CategoryLinux Programming

Games::SGF::Tournament is a Perl module for tournament statistics generator.

DateOct 6, 2010

AuthorAl Nikolov

Size12.3 KB

LicenseFreeware

PriceFree

PlatformLinux

CategoryLinux Programming