Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: XML::Twig and the monasteries XML

by Jenda (Abbot)
on Jun 02, 2019 at 18:41 UTC ( [id://11100852]=note: print w/replies, xml ) Need Help??


in reply to XML::Twig and the monasteries XML

You might want to try a different module, XML::Rules.

use strict; use XML::Rules; use Data::Dumper qw(Dumper); my $parser = XML::Rules->new( stripspaces => 15, rules => { 'type,author' => sub { return ( $_[0].'Id' => $_[1]->{id}, $_[ +0] => $_[1]->{_content}); }, field => sub { return ( $_[1]->{name} => $_[1]->{_content}); } +, data => 'pass no content', node => 'pass no content' } ); print Dumper($parser->parse(\*DATA)); __DATA__ <?xml version="1.0" encoding="Windows-1252"?> <node id="11100665" title="Re^5: What does $_ = qq~&quot;$_&quot;~ do? +" created="2019-05-28 16:28:57" updated="2019-05-28 16:28:57"> <type id="11"> note</type> <author id="830549"> haukex</author> <data> <field name="doctext"> &lt;p&gt;More fun facts! I once wrote a script to search a word list f +or words that make valid regexen which convert one valid word into an +other.&lt;/p&gt; &lt;c&gt; $ perl -le 'print bangs =~s engender' bands $ perl -le 'print halved =~s avatar' halted $ perl -le 'print stove =~s evener' stone &lt;/c&gt; </field> <field name="root_node"> 11100593</field> <field name="parent_node"> 11100640</field> <field name="reputation"> 21</field> </data> </node>

Jenda
Enoch was right!
Enjoy the last years of Rome.

Replies are listed 'Best First'.
Re^2: XML::Twig and the monasteries XML
by LanX (Saint) on Jun 09, 2019 at 18:21 UTC
    Thanks, will have a look at it! :)

    Cheers Rolf

    Enoch was right wing! ;P

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11100852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-29 01:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found