Get your CodeRanch badge!*
The moose likes XML and Related Technologies and the fly likes HTML Tags in XML file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "HTML Tags in XML file" Watch "HTML Tags in XML file" New topic
Author

HTML Tags in XML file

Neeraj Singhal
Ranch Hand

Joined: Aug 13, 2000
Posts: 49
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

Joined: Nov 22, 2000
Posts: 177
Hi, what about <b> and </b>?
Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
shoot, I meant "&" "lt" ";" "b" "&" "gt" ";" and "&" "lt" ";" "/" "b" "&" "gt" ";" .
Neeraj Singhal
Ranch Hand

Joined: Aug 13, 2000
Posts: 49
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

Joined: Oct 30, 2000
Posts: 27
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
 
 
subject: HTML Tags in XML file
 
Similar Threads
Transforming URL
Empty element
why is the output not displayed
Simple XSL problem: parent attributes
HTML tag within XML