vagabonding electron has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I use XML::Rules to parse a huge XML document. As a Perl amateur I'm generally happy with the module since it does what I mean. Now however I'm stuck with the following problem.
Here is the XML chunk.
Update:The desired output presentation was not correct in the original, you can see it in the spoiler below.
The output ought to be the following:
The following code chunk is a way out so that I at least get an info about the "Outpatient_Clinic_Special", but it is just a description, not the keys.
Thanks in advance!
VE
I use XML::Rules to parse a huge XML document. As a Perl amateur I'm generally happy with the module since it does what I mean. Now however I'm stuck with the following problem.
Here is the XML chunk.
<Outpatient_Services> <Outpatient_Service> <Outpatient_Clinic> <AM_Key>AM01</AM_Key> <Description>Description of the Outpatient_Clinic</Description> <Explanations>Explanations to the Outpatient_Clinic</Explanations> </Outpatient_Clinic> </Outpatient_Service> <Outpatient_Service> <Outpatient_Clinic> <AM_Key>AM01</AM_Key> <Description>Description of the Outpatient_Clinic</Description> <Explanations>Explanations to the Outpatient_Clinic</Explanations> </Outpatient_Clinic> </Outpatient_Service> <Outpatient_Service> <Outpatient_Clinic> <AM_Key>AM02</AM_Key> <Description>Description of the Outpatient_Clinic</Description> <Capacities_Outpatient_Clinic> <Care_Point> <VA_VU_Key_Outpatient_Clinic>VA01</VA_VU_Key_Outpatient_Clinic> </Care_Point> <Care_Point> <Other> <VA_VU_Other_Key_Outpatient_Clinic>VA00</VA_VU_Other_Key_Outpatient_Cl +inic> <Description>Other Care Point of the Outpatient Clinic</Description> </Other> </Care_Point> </Capacities_Outpatient_Clinic> </Outpatient_Clinic> </Outpatient_Service> <Outpatient_Service> <Outpatient_Clinic_Special> <AM_Special_Key>AM06</AM_Special_Key> <Description>Description of the Outpatient_Clinic</Description> <Capacities_Outpatient_Clinic_Special> <Capacity> <LK_Key>LK01</LK_Key> </Capacity> <Capacity> <LK_Key>LK02</LK_Key> </Capacity> </Capacities_Outpatient_Clinic_Special> <Explanations>Explanations to the Outpatient_Clinic</Explanations> </Outpatient_Clinic_Special> </Outpatient_Service> <Outpatient_Service> <Outpatient_Clinic> <AM_Key>AM04</AM_Key> </Outpatient_Clinic> </Outpatient_Service> <Outpatient_Service> <Outpatient_Clinic> <Other> <AM_Other_Key>AM00</AM_Other_Key> <Type>Type of the other Outpatient Clinic</Type> </Other> <Description>Description of the Outpatient Clinic</Description> <Capacities_Outpatient_Clinic> <Care_Point> <VA_VU_Key_Outpatient_Clinic>VA02</VA_VU_Key_Outpatient_Clinic> </Care_Point> <Care_Point> <Other> <VA_VU_Other_Key_Outpatient_Clinic>VA00</VA_VU_Other_Key_Outpatient_Cl +inic> <Description>Other Care Point of the Outpatient Clinic</Description> </Other> </Care_Point> </Capacities_Outpatient_Clinic> <Explanations>Explanations to the Outpatient_Clinic</Explanations> </Outpatient_Clinic> </Outpatient_Service> </Outpatient_Services>
Update:The desired output presentation was not correct in the original, you can see it in the spoiler below.
The output ought to be the following:
- Outpatient_Services: AM11: 1 AM07: 1 AM04: 1
<Reveal this spoiler or all in this thread>
However I need this not only for the AM-Keys but also for the LK-Keys and that is what I cannot achieve since there are two of them, not one.The following code chunk is a way out so that I at least get an info about the "Outpatient_Clinic_Special", but it is just a description, not the keys.
Could you please give me a hint?'Outpatient_Service' => sub { if (exists $_[1]->{Outpatient_Clinic}) { if ( exists $_[1]->{Outpatient_Clinic}->{Other} ) { return $_[1]->{Outpatient_Clinic}->{Description} => 1 } else { return $_[1]->{Outpatient_Clinic}->{AM_Key} => 1 } } elsif ( exists $_[1]->{Outpatient_Clinic_Special} ) { return $_[1]->{Outpatient_Clinic_Special}->{Description} => 1; + # as a way out. } else { } },
Thanks in advance!
VE
|
---|
Back to
Seekers of Perl Wisdom