Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Relating data parsed with XMLSimple

by Jenda (Abbot)
on Mar 30, 2010 at 11:42 UTC ( #831821=note: print w/replies, xml ) Need Help??


in reply to Relating data parsed with XMLSimple

The XML is not very well designed ... depending on the order of tags in a data oriented XML is a bad idea. Anyway ... do you like this output better?:

use strict; use XML::Rules; use Data::Dumper; my $data=q( <Data> <Name><Lname>xyz</Lname><Fname>abcd</Fname></Name> <Phone><Mobile>123456789</Mobile><Home>55656556</Home></Phone> <Phone><Mobile>123456789</Mobile><Home>55656556</Home></Phone> <Name><Lname>UTV</Lname><Fname>EFGH</Fname></Name> <Phone><Mobile>123456789</Mobile><Home>55656556</Home></Phone> </Data>); my $parser = XML::Rules->new( stripspaces => 7, rules => { _default => 'content', Name => 'as array no content', Phone => sub { #return; my ($tag,$attr,$context,$parents) = @_; if (! $parents->[-1]{Name}) { warn "<Phone> before <Name>!\n"; } else { push @{$parents->[-1]{Name}[-1]{Phones}}, $attr; } return }, Data => sub {$_[1]->{Name}}, } ); my $ref = $parser->parse($data); print Dumper($ref);

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

Replies are listed 'Best First'.
Re^2: Relating data parsed with XMLSimple
by mohan2monks (Beadle) on Mar 30, 2010 at 12:00 UTC

    Yes sir this output definately looks better but will have to install this module and check if this is possible to include in the existing code.

    Thank you very much

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://831821]
help
Chatterbox?
[Corion]: Two-way data binding means that if you change something in a text box, the corresponding variable in your Javascript gets updated immediately as well, and if you then change the variable, the corresponding text box also gets updated
[Corion]: That is a horrible approach that was also taken by Access, but if you have hooks that prevent automatic saving to the database, it is incredibly handy

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2017-03-30 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (355 votes). Check out past polls.