Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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 - {}

In reply to Re^3: How to return two and more values by parsing XML with XML::Rules? by Anonymous Monk
in thread How to return two and more values by parsing XML with XML::Rules? by vagabonding electron

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2018-01-16 20:26 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (191 votes). Check out past polls.