xml - Remove extra value using XSL -


how remove value being generated after transformation.

input:

<response status="200">     <idlist>         <idlists>             <idsec>                 <idfield>                     <idfields>                         <id>123456</id>                         <idstate>done</idstate>                     </idfields>                     <idfields>                         <id>12345634</id>                         <idstate>failed</idstate>                     </idfields>                 </idfield>             </idsec>         </idlists>         <code>56</code>         <msg>yet</msg>     </idlist> </response> 

xsl transforming it:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">     <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>         <xsl:strip-space elements="*"/>     <xsl:template match="/">         <xsl:if test="/response/idlist/idlists/idsec/idfield/idfields/id">             <xsl:apply-templates/>         </xsl:if>     </xsl:template>     <xsl:template match="idfields">         <cid>             <id>                 <xsl:value-of select="id"/>             </id>             <idstate>                 <xsl:value-of select="idstate"/>             </idstate>           </cid>     </xsl:template> </xsl:stylesheet> 

required output:

<cid>   <id>123456</id>   <idstate>done</idstate> </cid> <cid>   <id>12345634</id>   <idstate>failed</idstate> </cid> 

generated output after using above xsl:

<cid>   <id>123456</id>   <idstate>done</idstate> </cid> <cid>   <id>12345634</id>   <idstate>failed</idstate> </cid>56yet 

how remove 56yet output?

change

<xsl:template match="/">     <xsl:if test="/response/idlist/idlists/idsec/idfield/idfields/id">         <xsl:apply-templates/>     </xsl:if> </xsl:template> 

to

<xsl:template match="/">         <xsl:apply-templates select="/response/idlist/idlists/idsec/idfield/idfields[id]"/> </xsl:template> 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -