Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Tags in XML

Status
Not open for further replies.

MaKSiNG

Technical User
Dec 4, 2003
19
Hi All,

I have an XML file which contains HTML tags for formatting, eg. Bold, Paragraph, Lists, etc.

These are displayed in the XML as Entity References, eg. "& lt ;" and "& gt ;" for opening and closing tags.

I need this formating to remain, as the author of the content wishes this to draw emphasis to certain parts of his text.

The problem I have is that when I display the XML through my XSLT, the HTML tags are not exposed as formatting to the content but seen as content themselves, so I see them displayed amongst the text.

Is there a way to get around this?

TIA,
MaKS
 
Hi jel,

This doesn't seem to make any difference.

Here is a copy of my XSL:


<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;<xsl:eek:utput method=&quot;html&quot; version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; indent=&quot;yes&quot;/>

<xsl:template match=&quot;/&quot;>

<html>
<body width=&quot;100%&quot; bgcolor=&quot;#F7F9FB&quot;>

<p>
<xsl:for-each select=&quot;record/item/value/item&quot;>

<xsl:value-of select=&quot;value&quot;/><br/>

</xsl:for-each>
</p>

</body>
</html>

</xsl:template>
</xsl:stylesheet>


And here a copy of part of the XML:


<item name=&quot;c_mainbody&quot;>
<value>
<item name=&quot;pagetitle&quot;>
<value>This is the Page Title</value>
</item>
<item name=&quot;mainbody&quot;>
<value>& lt;h2& gt;Principle& lt;/h2& gt;

& lt;p& gt;This is simply text with HTML formating already applied since it was converted from a word doc.& lt;/p& gt;


(I had to put spaces after each '&')
Would you mind having a look and tell me where I am going wrong. Or if this is possible?

TIA,

MaKS


Thx,
MaKS
 
Ladies and Gentlemen,
Boys and Girls,

Here is the solution!

On the end of the value-of select statement:

<xsl:value-of select=&quot;value&quot; disable-output-escaping=&quot;yes&quot; />

This prevents the encoded characters, eg. '& lt;' from being escaped when the XSL renders the XML into HTML, hence allowing them to be seen as HTML Tags and formatting applied accordingly.

Thanks to those who had a go,

Thx,
MaKS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top