structure - Restructuring XML file -


i have client have drop down list added registration form lists of provinces in world country code. end, gave me this file. unfortunately, structure of data not work need do. below structure i'd have. there way automatically restructure data, perhaps using xslt or similar? thanks!

<countries>   <country code="us">     <region>alaska</region>     <region>california</region>   </country> </countries> 

this accomplished adding single template xslt identity transform:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">     <xsl:output method="xml" indent="yes"/>     <xsl:template match="node() | @*">        <xsl:copy>           <xsl:apply-templates select="node() | @*" />        </xsl:copy>    </xsl:template>     <xsl:template match="countries/*">        <country code="{name()}">           <xsl:apply-templates select="region"/>        </country>    </xsl:template>  </xsl:stylesheet> 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -