Parsing XML using command line -
how parse xml below contents?
<?xml version="1.0"?> <saw:ibot xmlns:saw="com.siebel.analytics.web/report/v1" version="1" priority="normal" jobid="36 "> <saw:schedule timezoneid="(gmt-05:00) eastern time (us & canada)" disabled="false"> <saw:start repeatminuteinterval="60" endtime="23:59:00" startimmediately="true"/> <saw:recurrence runonce="false"> <saw:weekly weekinterval="1" mon="true" tue="true" wed="true" thu="true" fri="true"/> </saw:recurrence> </saw:schedule> <saw:datavisibility type="recipient" runas="cgm"/> <saw:choose> <saw:when condition="true"> <saw:deliverycontent> <saw:headline> <saw:caption> <saw:text>availability parity alert next 14 days (@{nq_session.lbl_next_14_arriv al_days})</saw:text> </saw:caption> </saw:headline> <saw:conditionalreport/> </saw:deliverycontent> <saw:postactions/> </saw:when> ...skipping... al_days})</saw:text> </saw:caption> </saw:headline> <saw:conditionalreport/> </saw:deliverycontent> <saw:postactions/> </saw:when> <saw:otherwise/> </saw:choose> <saw:deliverydestinations> <saw:destination category="dashboard"/> <saw:destination category="activedeliveryprofile"/> </saw:deliverydestinations> <saw:recipients subscribers="true" customize="false" specificrecipients="false"> <saw:subscribers> <saw:user name="mbussey@xyz.com"/> <saw:user name="kimmy.chan@pqr.com"/> <saw:user name="chudgins@gmail.com"/> </saw:subscribers> </saw:recipients> <saw:conditionquery> <saw:reportrefnode path="/shared/quote/product/alerts/daily availability parity alert - next 14 days - content"/> </saw:conditionquery> </saw:ibot>
and retrieve below output?
mbussey@xyz.com kimmy.chan@pqr.com chudgins@gmail.com
also have 5 .xml file different set of parsing name value. anyway can parse , merge them in command line , output in 1 file ?
i have tried sed
, awk
options not helping me desired output.
this command parse xml document , use xpath extract name
attribute values element @ location /saw:ibot/saw:recipients/saw:subscribers/saw:user
xmlstarlet sel -t -v '/saw:ibot/saw:recipients/saw:subscribers/saw:user/@name' </tmp/xml
output
mbussey@xyz.com kimmy.chan@pqr.com chudgins@gmail.com
Comments
Post a Comment