I did this xslt, it grabs a value from a XML, I have parameters that I can send to the for each to get what I need, it works with no problem, my for each do a comparison and if the value matches my parameter then it's done.
Does anybody knows if that is a good way to do it ? I'm telling that because I'm new to XSLT and that's the way I figured out that might work with no problem. I wonder if a function would be a better solution, in terms of coding and speed.
Cheers!
XSLT:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="TransactionDataOfRequest">
<xsl:output method="text" indent="no"/>
<xsl:output omit-xml-declaration="yes" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:param name="param1" select="'ADM_1'"/>
<xsl:param name="param2" select="'ADM_2'"/>
<xsl:for-each select="//x:form/x:add">
<xsl:if test="@name=$param1">
Question1=<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="//x:form/x:add">
<xsl:if test="@name=$param2">
<xsl:variable name="test">
<xsl:value-of select="."/>
</xsl:variable>
Question2=<xsl:copy-of select="$test" />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<transaction xmlns="TransactionDataOfRequest" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<success>true</success>
<code>0</code>
<value>
<form>
<add name="ADM_1" title="Question 1" type="String" isList="false">No</add>
<add name="ADM_2" title="Question 2" type="String" isList="false">Yes</add>
</form>
</value>
</transaction>