Storing html tags within an xsl variable

*爱你&永不变心* 提交于 2019-12-02 03:59:25

You need to use <xsl:copy-of select="$something"/> instead of xsl:value-of.

I'll add some explanation of what's happening :)

The reason you're not getting the html tags is that the $something variable contains a dom fragment, not a string: the value-of element extracts the content of the node(s) the same way as the string() function does, so does not serialize the nodes.

This would provide, instead, a string representation of the html string you have and you can then print it out with value-of and disable-output-escaping:

<xsl:variable name="something"><![CDATA[<p>Hi there</p><p>How are you today?</p>]]></xsl:variable>

(see https://msdn.microsoft.com/en-us/library/ms256181(v=vs.110).aspx "The results are converted to a string, as by a call to the string() function")

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!