开发者

Xml transform with HTML in the source only returns text

开发者 https://www.devze.com 2023-03-29 21:36 出处:网络
I have an Xml transformation I need to do, but am having a bit of a struggle. The input Xml looks like this...

I have an Xml transformation I need to do, but am having a bit of a struggle.

The input Xml looks like this...

<?xml version='1.0' encoding='utf-8' ?>
<content>
     <div>Stuff Goes Here</div>
</content>

And the stylesheet looks like this...

<?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='html' />
     <xsl:template match='开发者_JAVA百科/'>
          <xsl:value-of select='content' disable-output-escaping='yes'   />
     </xsl:template>
</xsl:stylesheet>

I have got the transform working with c#, but it only returns "Stuff Goes Here" without the wrapping div tag.


Try this

<xsl:output method='html' />
<xsl:template match='/'>
    <xsl:copy-of select='content/div'/>
</xsl:template>
</xsl:stylesheet>

Outputs

<div>Stuff here</div>

Good Luck

0

精彩评论

暂无评论...
验证码 换一张
取 消