• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML Tags in XML file

 
Neeraj Singhal
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to give html tags like <b></b> in my xml file. but instead of rendering it, browser displays the tags as it is.
Can anybody suggest a way out.
thanx

The <b></b> tag in the following xml file is shown as it is.
-----------------------------------------------------
XML File: test.xml
-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<person>
<name>
<fname>Neeraj</fname>
<lname><b>Singhal</b></lname>
</name>
</person>
-----------------------------------------------------
XSL File: test.xsl
-----------------------------------------------------
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match="person">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="name">
<b>
<xsl:apply-templates/>
</b>
</xsl:template>
<xsl:template match="fname">
<i>
<xsl:value-of select="."/>
</i>
</xsl:template>
<xsl:template match="lname">
<strike>
<xsl:value-of select="."/>
</strike>
</xsl:template>
</xsl:stylesheet>
 
Bob Moranski
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, what about <b> and </b>?
 
Bob Moranski
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shoot, I meant "&" "lt" ";" "b" "&" "gt" ";" and "&" "lt" ";" "/" "b" "&" "gt" ";" .
 
Neeraj Singhal
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Bob,
but still it doesnt work and displays the sequence ("&" "lt" ";" "b" "&" "gt" ";" and "&" "lt" ";" "/" "b" "&" "gt" ";" ) in the form of tags ie <i></i> without rendering it.
 
prabhu palanisamy
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi neeraj,

change your xsl file like this
now your lame will be bold.
xml won't render html tags,it'll display as such.
<xsl:template match="lname">
<strike><b>
<xsl:value-of select="."/>
</strike><b>
</xsl:template>
</xsl:stylesheet>
bye
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic