EDN Admin
Well-known member
I have the following xml document. I want a new xml document and I only want the location information and I want to remove the namespacing. I have also included an xls that I have modified over and over but cannot get the results I need. I appreciate any help i can get?<?xml version="1.0" encoding="utf-8"?>
<stuff xmlns:n1="gary" xmlns:n2="troy
<n1:location>
<n1:address>1234 riverglen dr</n1:address>
<peeps>
<person>gary</person>
<person>troy</person>
<person>amanda</person>
</peeps>
</n1:location>
<n1:location>
<n1:address>2222 riverglen dr</n1:address>
<peeps>
<person>Larry</person>
<person>Mack</person>
</peeps>
</n1:location>
<n2:car>
<make>ford</make>
</n2:car>
<n2:car>
<make>chevy</make>
</n2:car>
</stuff>
my xsl:<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<xslutput method="xml" version="1.0" encoding="UTF-8" />
<xsl:template match="/
<NewStuff>
<xsl:apply-templates select="stuff"/>
</NewStuff>
</xsl:template>
<xsl:template match="stuff
<xsl:apply-templates select="location"/>
</xsl:template>
<xsl:template match="stuff/location
<xsl:element name="{local-name()}" >
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
View the full article
<stuff xmlns:n1="gary" xmlns:n2="troy
<n1:location>
<n1:address>1234 riverglen dr</n1:address>
<peeps>
<person>gary</person>
<person>troy</person>
<person>amanda</person>
</peeps>
</n1:location>
<n1:location>
<n1:address>2222 riverglen dr</n1:address>
<peeps>
<person>Larry</person>
<person>Mack</person>
</peeps>
</n1:location>
<n2:car>
<make>ford</make>
</n2:car>
<n2:car>
<make>chevy</make>
</n2:car>
</stuff>
my xsl:<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<xslutput method="xml" version="1.0" encoding="UTF-8" />
<xsl:template match="/
<NewStuff>
<xsl:apply-templates select="stuff"/>
</NewStuff>
</xsl:template>
<xsl:template match="stuff
<xsl:apply-templates select="location"/>
</xsl:template>
<xsl:template match="stuff/location
<xsl:element name="{local-name()}" >
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
View the full article