Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: How to return two and more values by parsing XML with XML::Rules?

by Anonymous Monk
on Nov 06, 2012 at 10:11 UTC ( #1002449=note: print w/replies, xml ) Need Help??

in reply to How to return two and more values by parsing XML with XML::Rules?

Your sample xml doesn't match your wanted data -- irritating
  • Comment on Re: How to return two and more values by parsing XML with XML::Rules?

Replies are listed 'Best First'.
Re^2: How to return two and more values by parsing XML with XML::Rules?
by vagabonding electron (Chaplain) on Nov 06, 2012 at 10:36 UTC
    Sorry, I did not mention that I have run
    'Capacities_Outpatient_Clinic_Special' => 'pass',
    before the mentioned chunk of the script.
    Thank you for pointing that out.
    Apart from that this is a fragment of a script that actually runs (only with fields translated into English). The above rule should not affect the code fragment however, perhaps I overook another mismatch?
    It must be the result presentation that has to be adjusted in my fragment - it should be:
    - Outpatient_Services: AM11: 1 AM07: 1 AM04: 1
      I was referring to the yaml, and FWIW, ysh doesn't like that YAML, which I assume is supposed to be

      This is what I came up with, which took waaay too long, the rules are hard to remember

      #!/usr/bin/perl -- use strict; use warnings; use XML::Rules; use Data::Dump qw/ dd /; my $ta = XML::Rules->new( qw/ stripspaces 8 /, rules => { 'Outpatient_Services' => 'no content', 'Outpatient_Service' => 'as array no content', #~ 'Outpatient_Clinic' => 'content by AM_Key', 'Outpatient_Clinic' => sub { #~ $rule->( $tag_name, \%attrs, \@context, \@parent_data, $parser) #~ my ($tagname, $attrHash, $contexArray, $parentDataArray, $parser) = + @_; my $amk = $_[1]->{AM_Key} ; return unless $amk; { $amk => 1 }; }, #~ _default => sub { $_[0] => $_[1]->{_content} }, _default => 'content', 'Outpatient_Clinic_Special' => undef, }, ); my $ref = $ta->parsefile( 'pm1002448.xml' ); dd $ref; use YAML(); print YAML::Dump( $ref); __END__ { Outpatient_Services => { Outpatient_Service => [ { AM01 => 1 }, { AM01 => 1 }, { AM02 => 1 }, {}, { AM04 => 1 }, {}, ], }, } --- Outpatient_Services: Outpatient_Service: - AM01: 1 - AM01: 1 - AM02: 1 - {} - AM04: 1 - {}
        Thank you very much!
        I noticed now ( but somewhat late :-) ) that your point was yaml output. I have corrected the output presentation in the original post and in the reply to your post.
        My main problem however ist that I need to represent the LK-Keys at the same hierarchy level as the AM-Keys. That is, I do need the Outpatient_Clinic_Special infos.
        Thank you again for your time I will try to build on your code.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002449]
[Corion]: Hehe - $work is a place where we have lots of (money) accounts, and lots of journals where every transaction is recorded. But our HR system where the accounts of hours worked and vacation days taken are stored, there is no real account of who changed ...
[Corion]: ... that balance, and when. And it seems to me that they somehow really messed up the database since the start of the year and have been frantically adding and subtracting numbers from the totals, but without trace ;)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2018-01-23 16:36 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (248 votes). Check out past polls.