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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML/XSL/HTML How can i display HTML stored in XML correct using XSL

Status
Not open for further replies.

frykke

Programmer
Dec 10, 2001
1
SE
In a database I have a text formatted with HTML-tags.
This text is retrieved in an element in an XML document. When i want to display the text in an HTML document, I am using an XSLT. The problem is that i.e. a <BR> tag is displayed as <BR> on the screen, I want it to be a line break. Can I in any way, using an XSLT, convert the XML representation of < and > back to the HTML representation ?
 
Hello,
I have the same problem and i found a beginning of answer :

Here is a copy of what i found :


&quot;9 - HTML in XML
Steve Muench


| We have
| some fields in our database that has HTML tags in the data to emphasize the
| text in the browser. A good example of this is to have parts of data being
| bold using <STRONG> tag, or displaying information
| using bullets with <UL>
| tags. I create XML using this data, and when I send the XML to the XSLT
| processor, I don't get any results back if there are any HTML tags in the
| data.
| Is there any way I can have the XSLT processor to ignore the HTML Tags?
If you are generating query results that contain HTML fragments like:

Code:
<ROWSET>
  <ROW>
    <SKU>12345</SKU>
    <DESC>Big Red Apple</DESC>
    <BLURB>
      <ul>
        <li><b>Delicious</b></li>
        <li><b>Nutritious</b></li>
      </ul>
    </BLURB>
  </ROW>
</ROWSET>
And you want the HTML &quot;blurb&quot; to showup &quot;verbatim&quot; in the output:

for this you'd use (assuming the current node is &quot;ROWSET/ROW&quot;):

Code:
   <xsl:value-of disable-output-escaping=&quot;yes&quot;
                           select=&quot;BLURB&quot;/>
This will produce: 

 <ul>
   <li><b>Delicious</b></li>
   <li><b>Nutritious</b></li>
 </ul>&quot;

I haven't verified if it works.
You could find it at this address :
 
add one more thing to TholsaDhoum's suggestion: put the contents of the BLURB tag into a CDATA. i just tried it and it worked.

i'm transforming the XML/XSL through MSXML 3.0 with ASP. hope this helps.

&quot;Until you have the courage to lose sight of the shore, you will not know the terror of being forever lost at sea.&quot; - a very wise man
 
I finally tried mine and it works too...

I do not know which solution is the best,
so make your choice, frikke!

Tchuss!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top