Why is your skeletal beginning longer than a complete solution?

use strict; use XML::Rules; use Text::CSV_XS; use FileHandle; my $csv = Text::CSV_XS->new({eol => "\n"}); my $parser = XML::Rules->new( rules => [ _default => 'content', HOUR_DATA => sub { $csv->print( $_[4]->{parameters}, [ map {$_[1]->{$_}} qw( LOCATION_NAME EFFECTIVE_DATE HOUR CLC DPT HUM DBT WDR WSP HIX WCH ) ]); return; } ] ); open my $FH, '>&STDOUT'; print $FH "# relation, date, time, CloudCoverPct, DewPointF, Humidity, + TempF, WindDirection, WindMPH, HeatIndexF, WindChillF\n"; $parser->parse( \*DATA, $FH); __DATA__ <?xml version="1.0" encoding="UTF-8"?> <WEATHER_DATA> <HOUR_DATA> <LOCATION_NAME>KCNU</LOCATION_NAME> <CLC>20</CLC> <DPT>73</DPT> <HUM>82</HUM> <HIX>84</HIX> <DBT>79</DBT> <WCH>79</WCH> <WDR>210</WDR> <WSP>17</WSP> <EFFECTIVE_DATE>08/20/2007</EFFECTIVE_DATE> <HOUR>14:00</HOUR> <TIME_GENERATED>08/20/2007 09:45:00</TIME_GENERATED> </HOUR_DATA> <HOUR_DATA> <LOCATION_NAME>KCOU</LOCATION_NAME> <CLC>100</CLC> <DPT>71</DPT> <HUM>87</HUM> <HIX>79</HIX> <DBT>75</DBT> <WCH>75</WCH> <WDR>190</WDR> <WSP>13</WSP> <EFFECTIVE_DATE>08/20/2007</EFFECTIVE_DATE> <HOUR>14:00</HOUR> <TIME_GENERATED>08/20/2007 09:45:00</TIME_GENERATED> </HOUR_DATA> </WEATHER_DATA>

In reply to Re: Using XML::XSLT to convert XML to CSV by Jenda
in thread Using XML::XSLT to convert XML to CSV by Photius

Title:
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, details, 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, summary, 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.