Topic "Trying to parse XML log."

Author Message
EdwinCollins
[View user's profile]

Joined: 2015-06-30
Posts: 1
Location: Louisville, KY
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="http://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="http://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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
The easiest solution would be to use Session.ExecuteCommand method of WinSCP .NET assembly from a PowerShell:

http://winscp.net/eng/docs/library_session_executecommand#powershell

Use returned CommandExecutionResult with its .ExitCode property.
http://winscp.net/eng/docs/library_commandexecutionresult
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License