How do I go about transforming the XML document below into result.xml? Basically what I'm aiming for is to remove one of the element but keeping the children. So I would like to remove the <Location> element but keep the <City> element (the <City> element being the child element of <Location>). Any pointers would be greatly appreciated. Thanks!
<User>
<TITLE>Mrs</TITLE>
<INITIALS>D</INITIALS>
<FIRST_NAME>Doris</FIRST_NAME>
<LAST_NAME>Smith</LAST_NAME>
<Location>
<City>London</City>
</Location>
</User>
** How do I transform this to**
<User>
<TITLE>Mrs</TITLE>
<INITIALS>D</INITIALS>
<FIRST_NAME>Doris</FIRST_NAME>
<LAST_NAME>Smith</LAST_NAME>
<City>London</City>
</User>
EggHeadCafe - Software Developer Portal of Choice
.NET GDI+ Icons - Drawing At Runtime For System Tray
http://www.eggheadcafe.com/tutorials/aspnet/c003531d-3152-471f-bfcc-daf22f84c65b/net-gdi-icons--drawing.aspx
How do I go about transforming the XML document below into result.xml? Basically what I'm aiming for is to remove one of the element but keeping the children. So I would like to remove the <Location> element but keep the <City> element (the <City> element being the child element of <Location>). Any pointers would be greatly appreciated. Thanks!
<User>
<TITLE>Mrs</TITLE>
<INITIALS>D</INITIALS>
<FIRST_NAME>Doris</FIRST_NAME>
<LAST_NAME>Smith</LAST_NAME>
<Location>
<City>London</City>
</Location>
</User>
** How do I transform this to**
<User>
<TITLE>Mrs</TITLE>
<INITIALS>D</INITIALS>
<FIRST_NAME>Doris</FIRST_NAME>
<LAST_NAME>Smith</LAST_NAME>
<City>London</City>
</User>
EggHeadCafe - Software Developer Portal of Choice
Easy "NO SCRIPT" DataGrid Tooltips in ASP.NET
http://www.eggheadcafe.com/tutorials/aspnet/c0d39393-80fe-481f-af5c-0e18fa4e2e43/easy-no-script--datagri.aspx
> How do I go about transforming the XML document below into result.xml? Basically what I'm aiming for is to remove one of the element but keeping the children. So I would like to remove the <Location> element but keep the <City> element (the <City> element being the child element of <Location>). Any pointers would be greatly appreciated. Thanks!
>
> <User>
>
> <TITLE>Mrs</TITLE>
>
> <INITIALS>D</INITIALS>
>
> <FIRST_NAME>Doris</FIRST_NAME>
>
> <LAST_NAME>Smith</LAST_NAME>
>
> <Location>
>
> <City>London</City>
>
> </Location>
>
> </User>
>
> ** How do I transform this to**
>
>
> <User>
>
> <TITLE>Mrs</TITLE>
>
> <INITIALS>D</INITIALS>
>
> <FIRST_NAME>Doris</FIRST_NAME>
>
> <LAST_NAME>Smith</LAST_NAME>
>
> <City>London</City>
>
> </User>
You need two templates, one is the identity transformation template
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
then a second template for the 'Location' elements that simply processes
any child nodes
<xsl:template match="Location">
<xsl:apply-templates/>
</xsl:template>
--
Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/