logging_xml » Revisions »
Differences
This shows you the differences between the selected revisions of the page.
2015-02-17 | 2015-02-17 | ||
limit XML acronym recognition + articles (martin) | xslt example (martin) | ||
Line 439: | Line 439: | ||
===== [[parse]] Interpreting/Parsing ===== | ===== [[parse]] Interpreting/Parsing ===== | ||
+ | |||
+ | ==== General ==== | ||
To parse the %%XML%% log, use any %%XML%% parser available. | To parse the %%XML%% log, use any %%XML%% parser available. | ||
Line 448: | Line 450: | ||
* [[guide_interpreting_xml_log|Guide to interpreting XML log for advanced scripting]] (.NET, C#). | * [[guide_interpreting_xml_log|Guide to interpreting XML log for advanced scripting]] (.NET, C#). | ||
+ | ==== [[xslt]] Transforming XML Log to Text Output Using XSLT Transformation ==== | ||
+ | You can use XSLT transformation to convert the %%XML%% log to plain text output (or any other format). | ||
+ | |||
+ | For example to generate a plain text list of successfully downloaded files from the following %%XML%% log (''log.xml''): | ||
+ | |||
+ | <code xml> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <session xmlns="http://winscp.net/schema/session/1.0" name="user@host" start="2015-01-30T06:45:57.008Z"> | ||
+ | <download> | ||
+ | <filename value="/path/file1.txt" /> | ||
+ | <destination value="C:\path\file1.txt" /> | ||
+ | <result success="true" /> | ||
+ | </download> | ||
+ | <download> | ||
+ | <filename value="/path/file2.txt" /> | ||
+ | <destination value="C:\path\file2.txt" /> | ||
+ | <result success="true" /> | ||
+ | </download> | ||
+ | </session> | ||
+ | </code> | ||
+ | |||
+ | use the following %%XSLT%% (''download.xslt''): | ||
+ | |||
+ | <code xml> | ||
+ | <?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:download[winscp:result[@success="true"]]/winscp:filename'> | ||
+ | <xsl:value-of select="@value"/> | ||
+ | <xsl:text>
</xsl:text> | ||
+ | </xsl:template> | ||
+ | </xsl:stylesheet> | ||
+ | </code> | ||
+ | |||
+ | You can execute it using any %%XSLT%% processor, e.g. ''[[http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=21714|msxsl.exe]]'': | ||
+ | |||
+ | <code> | ||
+ | msxsl.exe log.xml download.xsl | ||
+ | </code> | ||
+ | |||
+ | The output will be: | ||
+ | |||
+ | <code> | ||
+ | /path/file1.txt | ||
+ | /path/file2.txt | ||
+ | </code> |