Trying to parse XML log.

Advertisement

EdwinCollins
Joined:
Posts:
1
Location:
Louisville, KY

Trying to parse XML log.

Hello, I am using msxsl.exeto attempt to parse out the information I need. What I want to do is be able to send the out put to a txt file so I can use it in my batch scripts.

The xml log is as shown.

<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="https://winscp.net/schema/session/1.0" name="user@server.company.com" start="2015-08-03T18:31:36.636Z">
<upload>
<filename value="D:\SIT\VendorTransmissions\WSC_Transmission\outgoing\Prntelec.r.zip" />
<destination value="/connect2/WSCSuppression/Consolidated/Prntelec.r.zip" />
<result success="true" />
</upload>
<call>
<command value="/connect2/WSCSuppression/wsc_transmission.sh " />
<destination value="/connect2/WSCSuppression/" />
<output value="Start of Connect Direct session for WSC transfer
End of Connect Direct session for WSC" />
<exitcode value="4" />
<result success="false">
<message>Command '/connect2/WSCSuppression/wsc_transmission.sh '
failed with return code 4 and error message
.</message>
</result>
</call>
<failure>
<message>Command '/connect2/WSCSuppression/wsc_transmission.sh '
failed with return code 4 and error message
.</message>
</failure>
</session>

The XSLT file I have so far is
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:winscp="https://winscp.net/schema/session/1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match='winscp:call[winscp:result[@success="false"]]/winscp:exitcode'>
<xsl:value-of select="@value"/>
<xsl:text>&#xa;</xsl:text>
</xsl:template>
<xsl:template match='winscp:call[winscp:result[@success="false"]]/winscp:result'>
<xsl:value-of select="@value"/>
<xsl:text>&#xa;</xsl:text>
</xsl:template>
</xsl:stylesheet>

What I would like to have is to disply the exitcode tag and it value and then the result success value.

Example of output needed.
-------------------------------------
exitcode:4
result sucsess:false
-------------------------------------
Closest I get with above xslt is

4

Command '/connect2/WSCSuppression/wsc_transmission.sh '
failed with return code 4 and error message

I would even take a VBS soultion as well that I could use to read through the xml log and grab what I need.

Thanks

Edwin

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum