I am new to XML and XSLT and have a need to convert an Rest API response XML to CSV using XSLT and I need the XSLT doc to attach to the program. I tried several online tutorials but the transformation is reading all the elements not just the way I need them. Can some one please help me!
XML is below
<convertTo xmlns="http://xecdapi.xe.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://xecdapi.xe.com/schema/v1/convertTo.xsd" class=" cd-browser-extension">
<terms>http://www.xe.com/legal/dfs.php</terms>
<privacy>http://www.xe.com/privacy.php</privacy>
<to>USD</to>
<amount>1.0</amount>
<timestamp>2018-10-25T00:00:00Z</timestamp>
<from>
<rate>
<currency>AUD</currency>
<mid>1.4160280983</mid>
</rate>
<rate>
<currency>SGD</currency>
<mid>1.3814918146</mid>
</rate>
<rate>
<currency>EUR</currency>
<mid>0.8773448168</mid>
</rate>
<rate>
<currency>GBP</currency>
<mid>0.7760517332</mid>
</rate>
<rate>
<currency>CAD</currency>
<mid>1.3048398838</mid>
</rate>
<rate>
<currency>INR</currency>
<mid>73.3497808743</mid>
</rate>
</from>
</convertTo>
XSLT I was trying to output first 2 elements that I need.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:zz="http://xecdapi.xe.com" version="2.0" >
<xsl:template match="/">
<xsl:apply-templates select="zz:convertTo"/>
</xsl:template>
<xsl:template match="//zz:convertTo/zz:from/zz:rate">
<xsl:for-each select = "//zz:convertTo/zz:from/zz:rate">
<xsl:value-of select = "zz:currency"/>
<xsl:value-of select="zz:mid"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
CSV output needed
EffectiveTimestamp,FromCurrency,TargetCurrency,CurrencyRateType,CurrencyRate
2018-10-26,USD,INR,CURRENT,73.865