I'm having trouble getting my XML formatted correctly. I'm pulling data from a mySQL DB and it returns data as such.
<Customers>
<Customer Telephone="#" Country="#" Postcode="#" County="" Town="#" Address2="#" Address1="#" Surname="#" Forename="#" Suffix="#" Middlename="#" Title="#" Id="#"/>
</Customers>
I needed these attributes as element which with a quick search was fairly easy, using XLST the below file.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<Company>
<xsl:apply-templates/>
</Company>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:element name="{name()}"><xsl:value-of select="."/></xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:element name="{name()}"><xsl:value-of select="."/></xsl:element>
</xsl:template>
</xsl:stylesheet>
I end up with data as such.
<Company>
<Customers>
<Customer><Id>#</Id><Title>#</Title><Middlename>#</Middlename><Suffix>#</Suffix><Forename>#</Forename><Surname>#</Surname><Address1>#</Address1><Address2>#</Address2><Town>#</Town><County>#</County><Postcode>#</Postcode><Country>#</Country><Telephone>#</Telephone>
</Customer>
</Customers>
</Company>
However I need to add an '< Addresses > < /Addresses >' Element around (Address1 and Address2) using XSLT but really struggling on how to do this. Pretty much everything I've tried results in an error.
Thanks in advanced,