[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Cheesy XML wrangling



I love ready mixed instant reports by throwning anything into sort | uniq -c.


----- Original Message ----- From: "Jay Hannah" <jay@jays.net>
To: "Nebraska USA Perl Mongers of Omaha" <omaha-pm@pm.org>
Cc: "Omaha Linux User Group" <olug@olug.org>
Sent: Saturday, March 01, 2008 10:16 AM
Subject: [Omaha.pm] Cheesy XML wrangling


I've been doing a lot of cheesy XML parsing w/ command-line perl
lately. Perl is great at elegant XML handling too (I'm a fan of
XML::Twig), but it's hard to beat 30-second command line solutions to
answer simple questions...

Linux + GNU + Perl is awesome.   :)

j
preaching to the choir


$ head -3 RevData.DALMAN.20080301.xml
<revolutiondata asof="20080301091702" hotel="DALMAN" seq="20080301"
ver="1.5">
  <reservations>
    <res actrrev="972" bktime="20070915050836" cas="N"
doa="20071027" evt="notevent" exprrev="972" gcnt="1"
grp="13700106165" gtd="Y" id="2009477241" inlos="6"
intime="20071027100400" los="6" off="notoffer"
outtime="20071102041200" rcnt="1" rt="DELUXE" seg="06" src="WB"
st="R" time="20080301091703" xltime=""/>

$ grep '<res ' RevData.DALMAN.20080301.xml | perl -nle '/rt="(.*?)"/;
print $1' | sort | uniq -c
  50699 DELUXE
  16144 SUITES
   1180 UMAN

_______________________________________________
Omaha-pm mailing list
Omaha-pm@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm