使用XSLT解析XML字符串
发布时间:2020-12-16 07:51:44 所属栏目:百科 来源:网络整理
导读:我有一个 XML文档,其中包含一个包含HTML代码的TextBlock. TextBlock h1This is a header./h1 pThis is a paragraph./p/TextBlock 但是,在实际的XML中,它的编码如下: TextBlock lt;h1gt;This is a header.lt;/h1gt; lt;pgt;This is a paragraph.lt;/pgt;/Tex
我有一个
XML文档,其中包含一个包含HTML代码的TextBlock.
<TextBlock> <h1>This is a header.</h1> <p>This is a paragraph.</p> </TextBlock> 但是,在实际的XML中,它的编码如下: <TextBlock> <h1>This is a header.</h1> <p>This is a paragraph.</p> </TextBlock> 所以当我使用< xsl:value-of select =“TextBlock”/>它显示页面上的所有编码.有没有办法使用XSLT转换& lt;到<在TextBlock元素中? <xsl:value-of select="TextBlock" disable-output-escaping="yes"/> 结果: <h1>This is a header.</h1> <p>This is a paragraph.</p> Firefox有一个相应的错误:https://bugzilla.mozilla.org/show_bug.cgi?id=98168,其中包含很多评论,是一个有趣的阅读. 我现在正在寻找解决方案. 编辑 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import href="disable-output-escaping.xsl"/> <!-- https://bug98168.bugzilla.mozilla.org/attachment.cgi?id=434081 --> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/TextBlock"> <xsl:copy> <xsl:call-template name="disable-output-escaping"/> </xsl:copy> </xsl:template> </xsl:stylesheet> 通过Firebug进行检查时,结果看起来是正确的: <textblock> <h1>This is a header.</h1> <p>This is a paragraph.</p> </textblock> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |