Convert All XML Attributes to Elements

Songoku

New Member
I have a bunch of xml elements formatted like so:\[code\]<WP featured="yes" player="no" dancers="no" series="logos" archive="no" fanart="no" id="eclipse_logos_"> <seriesName>LOGOS</seriesName> <selection>ECLIPSE</selection> <imgurl>http://www.nba.com/warriors/photos/eclipse_logos_</imgurl> <res>1024x1024r(iPad/iPhone)?1280x1024r(Regular)?1440x900r(Widescreen)?1920x1080r(HDTV)?1920x1200r(Widescreen)</res></WP>\[/code\]that I want to turn into\[code\]<WP> <featured>yes</featured> <player>no</player> <dancers>no</dancers> <series>logos</series> <archive>no</archive> <fanart>no></fanart> <id>eclipse_logos_</id> <seriesName>LOGOS</seriesName> <selection>ECLIPSE</selection> <imgurl>http://www.nba.com/warriors/photos/eclipse_logos_</imgurl> <res>1024x1024r(iPad/iPhone)?1280x1024r(Regular)?1440x900r(Widescreen)?1920x1080r(HDTV)?1920x1200r(Widescreen)</res></WP>\[/code\]after some research, it seems that using an xslt stylesheet is the recommended way to go about this conversion:\[code\]<?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="@* | 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:stylesheet>\[/code\]However I am not very familiar with xsl stylesheets. Could someone walk me through the process of applying the transformation? Whenever I try, I get a blank page. I put the following at the top of my xml doc:\[code\]<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="http://stackoverflow.com/questions/10728017/wallpaper.xsl"?>\[/code\]and name the xsl file accordingly. Am I missing something?
 
Back
Top