将XML属性转换为元素XSLT
发布时间:2020-12-16 07:47:27 所属栏目:百科 来源:网络整理
导读:我试图将属性转换为子元素,即转为以下内容: WP featured="yes" player="no" dancers="no" series="logos" archive="no" fanart="no" id="eclipse_logos_" seriesNameLOGOS/seriesName selectionECLIPSE/selection imgurlhttp://www.nba.com/warriors/photos
我试图将属性转换为子元素,即转为以下内容:
<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> 成: <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>
试试这个:
<?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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |