Sponsored Content
Top Forums Shell Programming and Scripting Extract data from XML file and write in CSV file Post 302773435 by mohan sharma on Thursday 28th of February 2013 12:29:46 AM
Old 02-28-2013
Extract data from XML file and write in CSV file

Hi friend i have input as following XML file
Code:
<?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 ....

Last edited by fpmurphy; 02-28-2013 at 10:14 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract specific data from xml format file.

Hi, I need to extract the start time value (bold, red font) under the '<LogEvent ID="Timer Start">' tag (black bold) from a file with the following pattern. There are other LogEventIDs listed in the file as well, making it harder for me to extract out the specific start time that I need. . .... (7 Replies)
Discussion started by: 60doses
7 Replies

2. Shell Programming and Scripting

Help with shell script to extract data from XML file

Hello Scripting Gurus, I need help with extracting data from the XML file using shell script. The data is in a large XML and I need to extract the id values of all completedworkflows. Here is a sample of it. Input and output data is also in the attached text files. <wfregistry>... (5 Replies)
Discussion started by: yajaykumar
5 Replies

3. Shell Programming and Scripting

sed or awk to extract data from Xml file

Hi, I want to get data from Xml file by using sed or awk command. I want to get the following result : mon titre 1;Createur1;Dossier1 mon titre 1;Createur1;Dossier1 and save it in cvs file (fichier.cvs). FROM this Xml file (test.xml): <playlist version="1"> <trackList> <track>... (1 Reply)
Discussion started by: yeclota
1 Replies

4. Shell Programming and Scripting

Extract data from an XML file & write into a CSV file

Hi All, I am having an XML tag like: <detail sim_ser_no_1="898407109001000090" imsi_1="452070001000090"> <security>ADM1=????</security> <security>PIN1=????</security> <security>PIN2=????</security> ... (2 Replies)
Discussion started by: ss_ss
2 Replies

5. Shell Programming and Scripting

Data Extract from XML Log File

Please help me out to extract the Data from the XML Log files. So here is the data ERROR|2010-08-26 00:05:52,958|SERIAL_ID=128279996|ST=2010-08-2600:05:52|DEVICE=113.2.21.12:601|TYPE=TransactionLog... (9 Replies)
Discussion started by: raghunsi
9 Replies

6. Shell Programming and Scripting

How to extract data from csv file

Hello everybody, Here is my problem, I don't know anything about shell programming and my boss is actually asking me to develop a shell script in order to get values in a csv file from a specific date. Here is a sample of the csv file : Date;Enchaînement;Titre;Libellé ;calendrier;Heure début;Heure... (11 Replies)
Discussion started by: freyr
11 Replies

7. Shell Programming and Scripting

Extract and parse XML data (statistic value) to csv

Hi All, I need to parse some statistic data from the "measInfo" -eg. 25250000 (as highlighted) and return the result into line by line, and erasing all other unnecessary info/tag. Thought of starting with grep "measInfoID="25250000" but this only returns 1 line. How do I get all the output... (8 Replies)
Discussion started by: jackma
8 Replies

8. Shell Programming and Scripting

Extract data from XML file

Hi , I have input file as XML. following are input data #complex.xml <?xml version="1.0" encoding="UTF-8"?> <TEST_doc xmlns="http://www.w3.org/2001/XMLSchema-instance"> <ENTRY uid="123456"> <protein> <name>PROT001</name> <organism>Human</organism> ... (1 Reply)
Discussion started by: mohan sharma
1 Replies

9. Shell Programming and Scripting

Pass some data from csv to xml file using shell/python

Hello gurus, I have a csv file with bunch of datas in each column. (see attached) Now I have an .xml file in the structure of below: ?xml version="1.0" ?> <component id="root" name="root"> <component id="system" name="system"> <param name="number_of_A" value="8"/> ... (5 Replies)
Discussion started by: Zam_1234
5 Replies

10. Shell Programming and Scripting

Extract Data from XML file.

Hi Guys, I am in a need to extract data from a xml file. The XML file format is as below. <data jsxnamespace="propsbundle" locales=""> <locale> <!--Error messages starts--> <record jsxid="CHARPAIR001" jsxtext=" must be selected"></record> <record... (1 Reply)
Discussion started by: Showdown
1 Replies
XML::DOM::ValParser(3)					User Contributed Perl Documentation				    XML::DOM::ValParser(3)

NAME
XML::DOM::ValParser - an XML::DOM::Parser that validates at parse time SYNOPSIS
use XML::DOM::ValParser; my %expat_options = (KeepCDATA => 1, Handlers => [ Unparsed => &my_Unparsed_handler ]); my $parser = new XML::DOM::ValParser (%expat_options); eval { local $XML::Checker::FAIL = &my_fail; my $doc = $parser->parsefile ("fail.xml"); ... XML::DOM::Document was created sucessfully ... }; if ($@) { # Either XML::Parser (expat) threw an exception or my_fail() died. ... your error handling code here ... # Note that the XML::DOM::Document is automatically disposed off and # will be garbage collected } # Throws an exception (with die) when an error is encountered, this # will stop the parsing process. # Don't die if a warning or info message is encountered, just print a message. sub my_fail { my $code = shift; die XML::Checker::error_string ($code, @_) if $code < 200; XML::Checker::print_error ($code, @_); } DESCRIPTION
Use XML::DOM::ValParser wherever you would use XML::DOM::Parser and your XML will be checked using XML::Checker at parse time. See XML::DOM for details on XML::DOM::Parser options. See XML::Checker for details on setting the fail handler (my_fail.) The following handlers are currently supported, just like XML::DOM::Parser: Init, Final, Char, Start, End, Default, Doctype, CdataStart, CdataEnd, XMLDecl, Entity, Notation, Proc, Default, Comment, Attlist, Element, Unparsed. XML
::DOM::ValParser XML::DOM::ValParser extends from XML::Checker::Parser. It creates an XML::Checker object and routes all event handlers through the checker, before processing the events to create the XML::DOM::Document. Just like XML::Checker::Parser, the checker object can be retrieved with the getChecker() method and can be reused later on (provided that the DOCTYPE section of the XML::DOM::Document did not change in the mean time.) You can control which errors are fatal (and therefore should stop creation of the XML::DOM::Document) by filtering the appropriate error codes in the global $XML::Checker::FAIL handler (see "ERROR_HANDLING" in XML::Checker) and calling die or croak appropriately. Just like XML::Checker::Parser, XML::DOM::ValParser supports the SkipExternalDTD and SkipInsignifWS options. See XML::Checker::Parser for details. AUTHOR
Send bug reports, hints, tips, suggestions to Enno Derksen at <enno@att.com>. SEE ALSO
XML::DOM, XML::Checker ("SEE_ALSO" in XML::Checker) perl v5.8.0 2000-01-31 XML::DOM::ValParser(3)
All times are GMT -4. The time now is 04:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy