xsl,选择一个href并创建自己的xml标记

时间:2016-08-02 09:17:25

标签: xml xslt

我有一个html标签,如:

<a href="http://www.stackoverflow.com">www.stackoverflow.com</a>

并希望将其转换为:

<ownXmlelement adress="http://www.stackoverflow.com">www.stackoverflow.com</ownXmlelement>
有谁可以帮助我?这不起作用:(

<xsl:template match="a href">
<ownXmlelement><xsl:value-of select="."/></ownXmlelement>
</xsl:template>

谢谢!

1 个答案:

答案 0 :(得分:0)

您显示的输出不是有效的XML语法。也许你的意思是:

<ownXmlelement adress="http://www.stackoverflow.com">www.stackoverflow.com</ownXmlelement>

这将通过以下方式实现:

<xsl:template match="a">
    <ownXmlelement adress="{@href}">
        <xsl:value-of select="."/>
    </ownXmlelement>
</xsl:template>
相关问题