Need Assistance

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Need Assistance

lad.ratnesh@gmail.com
Greetings,

Kindly help me to solve this unix query.


A logfile called ‘logfile’ is full of very long lines each containing an XML payloads - one payload per line.  Each line looks similar to the following:

2006-04-21 03:57:55,858 [SunJsseListener0-6] DEBUG httpclient.wire.content - >> "<?xml version="1.0"?><payload><ident><alertid>ins-43-00-20060421035755-159</alertid><payloadref>ins-43-00-20060421035755-159</payloadref><username>adeptra.username</username><password>abcdef123</password><trackingtag>xpedite-20060421-5195</trackingtag><responseurl>https://response.adeptra.com:4601/AdeptraLinkResponse</responseurl></ident><action><insert><applicationid>43</applicationid><alert><vars><variable name="entityIndicator">
<![CDATA[0]]>
</variable><list name="custdata"><dictionary name=""><variable name="citystatezip">
<![CDATA[SHERMAN OAKS, CA,91403-1234]]>
</variable><variable name="lastname">
<![CDATA[SMITH]]>
</variable><variable name="cardType">
<![CDATA[4]]>
</variable><variable name="openDate">
<![CDATA[0605]]>
</variable><variable name="pinumber">
<![CDATA[4460111122223333]]>
</variable><variable name="firstname">
<![CDATA[JOHN]]>
</variable><variable name="dob">
<![CDATA[0001-01-01]]>
</variable><variable name="state">
<![CDATA[CA]]>
</variable><variable name="role">
<![CDATA[01]]>
</variable><variable name="zip">
<![CDATA[91403-1234]]>
</variable><variable name="expDate">
<![CDATA[0608]]>
</variable><variable name="city">
<![CDATA[SHERMAN OAKS]]>
</variable></dictionary></list><variable name="piCount">
<![CDATA[01]]>
</variable><dictionary name="work_phone"><variable name="cc
">
<![CDATA[1]]>
</variable><variable name="ac">
<![CDATA[   ]]>
</variable><variable name="number">
<![CDATA[     ]]>
</variable></dictionary><variable name="acctnumber">
<![CDATA[4460111122223333]]>
</variable><variable name="prn">
<![CDATA[4800]]>
</variable><variable name="homework">
<![CDATA[H]]>
</variable><variable name="GMToffset">
<![CDATA[07]]>
</variable><variable name="refreshURL">
<![CDATA[https://abc.adeptra.com:4601/AdeptraLinkResponse]]>
</variable><variable name="agent">
<![CDATA[0000]]>
</variable><variable name="sys">
<![CDATA[3275]]>
</variable><variable name="caseId">
<![CDATA[I110637B]]>
</variable><dictionary
name="home_phone"><variable name="cc">
<![CDATA[1]]>
</variable><variable name="ac">
<![CDATA[123]]>
</variable><variable name="number">
<![CDATA[1234567]]>
</variable></dictionary><variable name="msgtype">
<![CDATA[DTA]]>
</variable><variable name="dataTimestamp">
<![CDATA[20060421035755]]>
</variable><variable name="bankName">
<![CDATA[Wells Fargo]]>
</variable><variable name="clientID">
<![CDATA[5195]]>
</variable><list name="transaction_list"><dictionary name=""><variable name="trantime">
<![CDATA[2257]]>
</variable><variable name="approved">
<![CDATA[no]]>
</variable><variable name="merchant">
<![CDATA[PREMIER MEN]]>
</variable><variable name="sic">
<![CDATA[5651]]>
</variable><variable name="translatedPiNumber">
<![CDATA[4460111122223333]]>
</variable>
………………………………….
………………………………….
note!, the output shown above is all contained in one line in the file, it is NOT several lines!  In other words, “grep caseId logfile” will include all of the above.

3.a)  Write a command or script to run on a Linux system that could extract and output a list of ‘caseId’ parameters (as highlighted above in large text and italics) from such a file.
Reply | Threaded
Open this post in threaded view
|

Re: Need Assistance

Guru
Administrator
Hi
  Refer to this article of extracting tag values from xml.