From: Harry331 on
I have a data.xml file which I want to extract the data
to a display-friendly format.

I searched the web and find xgawk and a sample script,
outline.xgawk, which could do half what I want.
This script resulted in outlining the xml tags only.

OUTPUT (see below) - xml tags only; I want data to be
displayed as well.

For example, instead of 'SvceId' below, I want to
see 'SvceId : TheServiceID'. Also, I want all xml tags
to have their data displayed in a similar way.

See below for existing input & output.
The input data.xml is all on a single line; I fold it
here for clarity.

$ cat outline.xgawk
#!/usr/local/bin/xgawk
@load xml
XMLSTARTELEM {
printf("%*s%s", 2*XMLDEPTH-2, "", XMLSTARTELEM)
for (i=1; i<=NF; i++)
printf(" %s='%s'", $i, XMLATTR[$i])
print ""
}

$ fold -60 data.xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/
soap/envelope"><soapenv:Header><OpHdr><OpHdrVersNum>1.0</OpH
drVersNum><OpDefin><SvceId>TheServiceID</SvceId><OpId>LOGON<
/OpId><SvceVersNum>1.0</SvceVersNum></OpDefin></OpHdr><ISMHd
r><ISMHdrVersNum>1.0</ISMHdrVersNum><AppName>TESTAPP</AppNam
e><UserId>804f60d0382711dfaee1006190</UserId><EmplyUserId></
EmplyUserId><ClntId>0000064482</ClntId><ClntHostId>SERVER123
</ClntHostId><GloblLogId>ABC_LOGON12695437245150000000000000
000000000000027</GloblLogId><MsgInstcId>0000000011</MsgInstc
Id><UserDviceId>204.50.7.200</UserDviceId><InbndChanlId>W</I
nbndChanlId><SessnId>8776612754</SessnId><MsgCreatTmsp>2010-
03-25T19.02.16.641000+00:00</MsgCreatTmsp><RespeCde><RtrnCde
>08</RtrnCde><ReasCde>c2002</ReasCde><DiagText>Bad response
from MQCHO RC 12 Reas 000000 Comp code 000002 ******TIMEOUT*
*****</DiagText></RespeCde></ISMHdr></soapenv:Header><soapen
v:Body><LogonImsg><IFSMsgHeader><ConsumerId></ConsumerId><Lo
caleLanguage>en</LocaleLanguage><PrimaryConsumerId></Primary
ConsumerId><FulfillerSessionId></FulfillerSessionId><Changab
leConsumerId>804f60d0382711dfaee1006190</ChangableConsumerId
><LocaleCountry></LocaleCountry><PermanentConsumerId></Perma
nentConsumerId></IFSMsgHeader><IfsCnsmrScrtyDtlTg><PswdIdTg
binaryEncoding="base64Binary">Z5S08hIuV2Gqz5H9pMD29BZoTxAxCz
WREtiEJm8LAeDLsbifRmuUnviyQcGx3ypt5H7LEAvphttEsegut9jVJgWSKc
aCPu1bO77J2sxKwCcAl2LlpE0WLCbS5P9Gpk/CwwxJBCrhXDB7h+rLIBEm+S
46vVVFDoz9wkw9DLrQ5iE=</PswdIdTg><ScrtyIdTg binaryEncoding="
base64Binary">R6fIY0b82mxFKtJl5sC7bmtfbaOKAVjokdYtAvmeINMCN8
626dBibMcEspF1LNTs+8SxqPwvNEkJCD3oJMHfrKlUZ5vge91Dh/9Tw3BfPP
n/ccInh2ktyWUpArqa4e/vm1prLn4UJ6IT31nE4MyLG+d5f9zcLay1sFy9s8
H0OtY=</ScrtyIdTg><PswdEncryptTpClTg>1</PswdEncryptTpClTg><S
crtyEncryptTpClTg>1</ScrtyEncryptTpClTg></IfsCnsmrScrtyDtlTg
><IfsCnsmrPdDtlTg><SwPdNmClTg>ValueMissing</SwPdNmClTg><SwPd
VersNbrTg>M</SwPdVersNbrTg><OperSystNmTg>ValueMissing</OperS
ystNmTg><ClientDtTg><GmtOfstMinsValTg>0</GmtOfstMinsValTg></
ClientDtTg></IfsCnsmrPdDtlTg><AddlLogonInfoTg><DisclIndTpClT
g>0</DisclIndTpClTg></AddlLogonInfoTg><IfsCnsmrIdTg><ChCnsmr
IdTg>804f60d0382711dfaee1006190</ChCnsmrIdTg></IfsCnsmrIdTg>
</LogonImsg></soapenv:Body></soapenv:Envelope>



$ xgawk -f outline.xgawk data.xml
soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelo
soapenv:Header
OpHdr
OpHdrVersNum
OpDefin
SvceId
OpId
SvceVersNum
ISMHdr
ISMHdrVersNum
AppName
UserId
EmplyUserId
ClntId
ClntHostId
GloblLogId
MsgInstcId
UserDviceId
InbndChanlId
SessnId
MsgCreatTmsp
RespeCde
RtrnCde
ReasCde
DiagText
soapenv:Body
LogonImsg
IFSMsgHeader
ConsumerId
LocaleLanguage
PrimaryConsumerId
FulfillerSessionId
ChangableConsumerId
LocaleCountry
PermanentConsumerId
IfsCnsmrScrtyDtlTg
PswdIdTg binaryEncoding='base64Binary'
ScrtyIdTg binaryEncoding='base64Binary'
PswdEncryptTpClTg
ScrtyEncryptTpClTg
IfsCnsmrPdDtlTg
SwPdNmClTg
SwPdVersNbrTg
OperSystNmTg
ClientDtTg
GmtOfstMinsValTg
AddlLogonInfoTg
DisclIndTpClTg
IfsCnsmrIdTg
ChCnsmrIdTg

$

TIA

From: Hermann Peifer on
Harry331 wrote:
>
> I searched the web and find xgawk and a sample script,
> outline.xgawk, which could do half what I want.
> This script resulted in outlining the xml tags only.
>

I have a modified outline.awk script, that prints something like:

soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope'
soapenv:Header
OpHdr
OpHdrVersNum '1.0'
OpDefin
SvceId 'TheServiceID'
OpId 'LOGON'
SvceVersNum '1.0'
(...)

Drop me a mail in case you are interested.
I guess this issue is somewhat OT, here in c.u.s.

Hermann