Data Extract from XML Log File


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Data Extract from XML Log File
# 1  
Old 08-27-2010
Data Extract from XML Log File

Please help me out to extract the Data from the XML Log files.

So here is the data

Code:
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
|LOG_LEVEL=6|CLASS=Gateway|OBJECT=/services/olive|PROVIDERID=http://plss2132-vip.corp.sprint.com:7003
/bnc/services/EsaPort|CONSUMERID=|OPERATION_NAME=getEsaList|MsgID=|TOTAL_TIME=9385|DP_TIME=13|REQUEST_MESSAGE=<soapenv:Envelop
e xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://sch
emas.xmlsoap.org/soap/envelope/"><soapenv:Body><getEsaList xmlns="http://olive.sprint.com/jws/esa">
<billingAccountNumber xmlns=""> 2345689</billingAccountNumber><DeviceNumber xmlns="">null</DeviceNumber><startDate xmlns="">20100526</startD
ate><endDate xmlns="">20100826</endDate><applicationId xmlns="">eCare</applicationId></getEsaList></soapenv:Body></soapenv:Env
elope>|RESPONSE_MESSAGE=<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2
001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Serve
r.generalException</faultcode><faultstring/><detail><ns1:fault xmlns:ns1="http://olive.com/jws/esa"><message>No Electron
ic Service Agreement found within Olive for the Account NUmber and date criteria provided</message>

Only thing is im interested for only 2 fields

<billingAccountNumber xmlns=""> 2345689</billingAccountNumber>
<Message>

Please help me out.
# 2  
Old 08-27-2010
I know this is still not complete but i m going for lunch will post after that.

Code:
sed -n '/<message>/,/<\/message>/p' filename

# 3  
Old 08-27-2010
Try:
Code:
awk '{gsub(/\n/," ")}/^billingAccountNumber/||/^message/{printf RS$0; getline; print RS$0}' RS='<' infile

Result:
Code:
<billingAccountNumber xmlns=""> 2345689</billingAccountNumber>
<message>No Electron ic Service Agreement found within Olive for the Account NUmber and date criteria provided</message>

# 4  
Old 08-27-2010
Please have look into this. The search should be done from multiple files . File names range is given like this

Service_LogGroup1
Service_LogGroup2
Service_LogGroup3
Service_LogGroup4
Service_LogGroup5

Im getting this error.

Code:
awk '{gsub(/\n/," ")}/^billingAccountNumber/||/^message/{printf RS$0; getline; print RS$0}' RS='<' Service_LogGroup[1-5]_2010-08-26.log
awk: syntax error near line 1
awk: illegal statement near line 1

# 5  
Old 08-27-2010
Hi, you should be able to specify multiple files..
Are you on Solaris? Then use nawk or /usr/xpg4/bin/awk instead of standard awk
# 6  
Old 08-27-2010
Im Using Solaris 10, so shall i use NAWK
# 7  
Old 08-27-2010
Either one...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

How to extract data from XML file using shell scripting?

Hi , I have input file as XML. following are input data #complex.xml Code: <?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: arun_kohan
1 Replies

3. Shell Programming and Scripting

How to extract data from xml file using shell scripting?

Hi evry1, This is my 1st post in this forum.Pls help me I want to extract some data froma xml file which has 2000 lines using shell scripting. Actually my xml file has some "audio and video codes" which i need to arrange in a column wise format after extracting it using shell scripting.I... (4 Replies)
Discussion started by: arun_kohan
4 Replies

4. Shell Programming and Scripting

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>... (3 Replies)
Discussion started by: mohan sharma
3 Replies

5. 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

6. Shell Programming and Scripting

Extract XML message from a log file using awk

Dear all I have a log file and the content like this file name: temp.log <?xml version="1.0" encoding="cp850"?> <!DOCTYPE aaabbb SYSTEM '/dtdpath'> <aaabbb> <tranDtl> <msgId>000001</msgId> </tranDtl> ..... </aaabbb> ... ... (1 Reply)
Discussion started by: on9west
1 Replies

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question