CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
extract xml tags from log

 



kvok
Novice

Nov 13, 2016, 12:00 PM

Post #1 of 3 (1619 views)
extract xml tags from log Can't Post

Hi,

Im fighting with extraction of text from log file :
here is log example:

Code
<Command 
TransID="312312886045711_8888147741212"
user="root">
<Exec
param_a="214033886045711"
param_b="692872054"
State="ACTIVE"></Exec>
</Command> serviceName=Exec state=5 stateLabel=TERMINATED submissionDate=1477479738152 TransID=312312886045711_8888147741212]
2016/11/11 13:08:19 <DEBUG > logon.filename: TAR
2016/11/11 13:08:19 <DEBUG > logon.connection: root/********
2016/11/11 13:08:19 <DEBUG > execSynchronousCommand.filename: TAR
2016/11/11 13:08:19 <DEBUG > kexecCommand.command: <Command TransID="9090988766544_1477479739082"><Exec param_a="9090988766544" param_b="123456789999" State="ACTIVE"/></Command>
2016/11/11 13:08:19 <DEBUG > convertSEE2WS.invocation: [Invc ID=244186092 user=root endingExecutionDate=1477479739257 endingStatus=1 endingStatusLabel=SUCCEEDED expDATE=1477480639236 processingDate=0 resultData=
<Command
TransID="9090988766544_1477479739082"
user="root">
<Exec
param_a="9090988766544"
param_b="123456789999"
State="ACTIVE"></Exec>
</Command> serviceName=Exec state=5 stateLabel=TERMINATED submissionDate=1477479739236 TransID=9090988766544_1477479739082]
2016/11/11 13:08:11 <DEBUG > logon.filename: TAR
2016/11/11 13:08:11 <DEBUG > logon.connection: root/********
2016/11/11 13:08:11 <DEBUG > execCommand.filename: TAR
2016/11/11 13:08:11 <DEBUG > execCommand.command: <Command TransID="213432544624952_1235479746767"><Exec param_a="134343248849848" param_b="764543455" State="ACTIVE"/></Command> serviceName=Exec state=5 stateLabel=TERMINATED submissionDate=1
2016/11/11 13:08:11 <DEBUG > convertSEE2WS.invocation: [Invc ID=244186093 user=root endingExecutionDate=1477479746186 endingStatus=1 endingStatusLabel=SUCCEEDED expDATE=1477480646143 processingDate=0 resultData=
<Command
TransID="213432544624952_1235479746767"
user="root">
<Exec
param_a="134343248849848"
param_b="764543455"
State="ACTIVE"></Exec>
</Command> serviceName=Exec state=5 stateLabel=TERMINATED submissionDate=1477479746143 TransID=213432544624952_1235479746767]


and I need as output :

Code
<Command 
TransID="312312886045711_8888147741212"
user="root">
<Exec
param_a="214033886045711"
param_b="692872054"
State="ACTIVE"></Exec>
</Command>
Command
TransID="213432544624952_1235479746767"
user="root">
<Exec
param_a="134343248849848"
param_b="764543455"
State="ACTIVE"></Exec>
</Command>


Thanks in advance for your comments


Laurent_R
Veteran / Moderator

Nov 13, 2016, 3:31 PM

Post #2 of 3 (1612 views)
Re: [kvok] extract xml tags from log [In reply to] Can't Post

Hmm, this is not a site for providing ready made code for free. This is a site for helping you, provided you show some efforts in doing it yourself.

We can help you correcting existing code, or giving some clues on how to do things, but we are generally not going to make your work for you, nor provide ready-made solutions for homework. Can you please show what code you've written and explain why it does not fit your needs?


BillKSmith
Veteran

Nov 13, 2016, 5:11 PM

Post #3 of 3 (1610 views)
Re: [kvok] extract xml tags from log [In reply to] Can't Post

In order to get the answer you want, you not only must follow Laurent's suggestions, you must clarify your requirements. I assume that the missing "<" from the second command is a typo. I cannot even guess why you only want two of the three command blocks in your input file.

This input is not easy to parse. I strongly recommend that you start by trying to find a module which can do it. My attempts to use a regex have all failed.

The long records in your input are hard to copy accurately and make your post hard to read. Attach the file rather than pasting it into your post.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives