Extract data from XML file and write in CSV file

Hi friend i have input as following XML file

<?xml version="1.0"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02">
 <BkToCstmrDbtCdtNtfctn>
	<GrpHdr><MsgId>LBP-RDJ-TE000000-130042430010001001</MsgId><CreDtTm>2013-01-04T03:21:30</CreDtTm></GrpHdr>
	<Ntfctn><Id>camt.054.001.02.rdd</Id><CreDtTm>2013-01-04T03:21:30</CreDtTm><Acct><Id><IBAN>FR58XXXXXXXXXXXXXXXXXXXXXXX</IBAN></Id><Ccy>EUR</Ccy><Nm>RAISON SOCIALE EMETTEUR</Nm><Svcr><FinInstnId><BIC>PSSTFRPPXXX</BIC></FinInstnId></Svcr></Acct><TxsSummry><TtlCdtNtries><NbOfNtries>0</NbOfNtries><Sum>0</Sum></TtlCdtNtries><TtlDbtNtries><NbOfNtries>1</NbOfNtries><Sum>41.40</Sum></TtlDbtNtries></TxsSummry>
		<Ntry><NtryRef>19020121227017581000046600100000001</NtryRef><Amt Ccy="EUR">41.40</Amt><CdtDbtInd>DBIT</CdtDbtInd><Sts>BOOK</Sts><BookgDt><Dt>2013-01-03</Dt></BookgDt><ValDt><Dt>2013-01-03</Dt></ValDt><BkTxCd><Domn><Cd>PMNT</Cd><Fmly><Cd>RDDT</Cd><SubFmlyCd>UPDD</SubFmlyCd></Fmly></Domn><Prtry><Cd>B3 4722</Cd></Prtry></BkTxCd>
		   <NtryDtls><TxDtls><Refs><AcctSvcrRef>QR943Y02851005</AcctSvcrRef><EndToEndId>P2012T4-C C0000025</EndToEndId><MndtId>RUM</MndtId></Refs><AmtDtls><InstdAmt><Amt Ccy="EUR">41.40</Amt></InstdAmt></AmtDtls><RltdPties><Dbtr><Nm>BENEFICIAIRE</Nm></Dbtr><DbtrAcct><Id><IBAN>FR56YYYYYYYYYYYYYYYYYYYYYYY</IBAN></Id><Ccy>EUR</Ccy></DbtrAcct></RltdPties><RmtInf><Ustrd>MOTIF DE PAIMENT</Ustrd></RmtInf><RltdDts><IntrBkSttlmDt>2012-12-27</IntrBkSttlmDt></RltdDts><RtrInf><Orgtr><Id><OrgId><BICOrBEI>CMCIFRPPXXX</BICOrBEI></OrgId></Id></Orgtr><Rsn><Cd>MD01</Cd></Rsn></RtrInf></TxDtls></NtryDtls>
		</Ntry>
	</Ntfctn>
 </BkToCstmrDbtCdtNtfctn>
</Document>

and i want to extract <GrpHdr> value and <IBAN> value from XML file and write into csv file ..please help me ....

Hi Mohan,

There are sub-tags for "GrpHdr". Please post which value you want.
Second, Multiple tags for "IBAN" is present. Again please be specific.

Third and most important, Please use code-tags.
Please scroll down this page in Quick-Reply section for help regarding how to use.

Thanks clx for your reply.
actualy i dont know about code-tages.

and in (1)for GrpHdr ,i dont want output now because requirement is changed but for
(2) IBAN i want output= FR58XXXXXXXXXXXXXXXXXXXXXXX

i tried with this query
xml pyx banko.xml | xml p2x | xml sel -T -t -m Document/BkToCstmrDbtCdtNtfctn/Ntfctn/Acct/Id -s A:T:- "@IBAN" -v "IBAN" -n

it works only when i am removing attribute of <Amt Ccy="EUR">41.40</Amt> as <Amt>41.40</Amt> then it works but my input is as above given...

---------- Post updated at 12:23 PM ---------- Previous update was at 12:21 PM ----------

So, do you want something like this?

awk -F "<IBAN>|</IBAN>" '/<IBAN>/ {print $2}' xmlfile
FR58XXXXXXXXXXXXXXXXXXXXXXX
FR56YYYYYYYYYYYYYYYYYYYYYYY
$