I have an incoming XML file with a list structure:
<list>
<listItem>
<name>elementOne</name>
<value>elementOneValue</name>
</listItem>
<listItem>
<name>elementTwo</name>
<value>elementTwoValue</name>
</listItem>
</list>
Which I am trying to convert to this structure:
<elementOne>elementOneValue</elementOne>
<elementTwo>elementTwoValue</elementTwo>
This is easy logic to implement with XSL, but I'm running into complications.
<xsl:for-each select="/list/listItem">
<xsl:element name="<xsl:value-of select="name"/>">
<xsl:value-of select="value"/>
</xsl:element>
</xsl:for-each>
Doesn't work because I assume the sequential double quotes are breaking the <xsl:element>
tag
<xsl:for-each select="/list/listItem">
<<xsl:value-of select="name"/>>
<xsl:value-of select="value"/>
</<xsl:value-of select="name"/>>
</xsl:for-each>
Doesn't work because I can't use <<
or >>
and
<xsl:for-each select="/list/listItem">
<<xsl:value-of select="name"/>>
<xsl:value-of select="value"/>
</<xsl:value-of select="name"/>>
</xsl:for-each>
Doesn't work because I end up with > and < in my code instead of XML parseable <
or >
. I expected this to be a very easy solution but I can't find any records for it on the internet. What is the simple fix I'm overlooking?
<xsl:element>
. :) – Dishwasher