...

View Full Version : How to pass HTML within XML Tags



addi
06-22-2009, 05:28 AM
Hello all –

My question is - how can I pass the following HTML code in the <Description> XML tag a for Product XML package. Currently, I pass the following via XML and it works.

<Description> This goes in the Product Description area</Description>
I then later go into Product details via an Admin menu and change the format as follows.

<h4><span style="FONT-SIZE: 12pt; COLOR: #0000cd; BACKGROUND-COLOR: #ffffe0"> This goes in the Product Description area </span></h4>


I would however like to format it on the go via XML if at all possible.


My second question is around larger formatting issue. The following is working HTML code, and if possible I would like to know how I can pass the following via XML. The code would go within the <Description> tag, but I don’t know how would I format or pass the values.


<p>Nestled inside their shells, pearls are almost as sweet as Mothers love.
The pendant may be ordered with with a chain or braclets.
Exclusively from us.</p>
<ul>
<li>sterling-silver pendant with sterling chain </li>
<li>freshwater pearls measure 3 mm </li>
</ul>
<table cellspacing="1" cellpadding="0" width="356" border="0">
<tbody>
<tr>
<td>
<img height="1" alt="" src="../content/images/spacer.gif" width="146" border="0" /></td>
<td>
<img height="1" alt="" src="../content/images/spacer.gif" width="210" border="0" /></td>
</tr>
<tr>
<td align="middle" bgcolor="#e8eff9" colspan="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif"><span style="FONT-WEIGHT: bold">Product Details</span> </span></td>
</tr>
<tr>
<td class="pptype" valign="top" colspan="2"><span style="FONT-WEIGHT: bold">Metal Information:</span></td>
</tr>
<tr>
<td class="ppname" valign="top" bgcolor="#e8eff9" colspan="2">Sterling Silver</td>
</tr>
<tr>
<td class="pptype" valign="top" colspan="2"><span style="FONT-WEIGHT: bold">Component Information:</span></td>
</tr>
<tr>
<td class="ppname" valign="top" bgcolor="#e8eff9" colspan="2">Lacing</td>
</tr>
</tbody>
</table>

I would be very grateful if someone can help me with this.

Thanks,

addi

Alex Vincent
06-22-2009, 06:30 AM
The first question I have is what technologies do you have at your disposal? Is this a server-side transformation (Perl, PHP, Python, etc.), or a client-side one (JavaScript, XSLT via <?xml-stylesheet ?> processing instruction)?

This is one of the more common questions we get... maybe liorean or another frequent contributor can put together a one-page forum thread - or an article for JavaScriptKit, CF's sister site - for XML transformations.

Bill Posters
06-22-2009, 06:42 AM
Possibly a little down and dirty (or not), but I tend to use CDATA tags.
The XML doc will consider the markup as a character string, but once you insert it into the markup doc, it will behave as normal markup.

http://www.w3.org/TR/REC-xml/#sec-cdata-sect

e.g.

<Description><![CDATA[<p>This goes in the Product Description area</p>]]></Description>

gkumar
07-03-2009, 12:58 PM
Before I ask the question, I will acknowledge that the question is more about XML/HTML, rather than ASPDNSF or WSI. However, I thought someone in this forum may already know they answer and perhaps may be able to help.

My question is - how can I pass the following HTML code in the <Description> XML tag for Product XML package, such that I donít have to go through Admin menu later to format it. Currently, I pass the following via XML and it works.

<Description> This goes in the Product Description area</Description>
I then later go into Product details via Admin menu and change the format as follows.

<h4><span style="FONT-SIZE: 12pt; COLOR: #0000cd; BACKGROUND-COLOR: #ffffe0"> This goes in the Product Description area </span></h4>
I would however like to format it on the go via XML if at all possible.
My second question is around larger formatting issue. Currently, I use the following format for Product description directly via Admin menus. The following is working HTML code, and if possible I would like to know how I can pass the following via XML. The code would go within the <Description> tag, but I donít know how would I format or pass the values.
<p>Nestled inside their shells, pearls are almost as sweet as Mothers love.
The pendant may be ordered with with a chain or braclets.
Exclusively from us.</p>
<ul>
<li>sterling-silver pendant with sterling chain </li>
<li>freshwater pearls measure 3 mm </li>
</ul>
<table cellspacing="1" cellpadding="0" width="356" border="0">
<tbody>
<tr>
<td>
<img height="1" alt="" src="../content/images/spacer.gif" width="146" border="0" /></td>
<td>
<img height="1" alt="" src="../content/images/spacer.gif" width="210" border="0" /></td>
</tr>
<tr>
<td align="middle" bgcolor="#e8eff9" colspan="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif"><span style="FONT-WEIGHT: bold">Product Details</span> </span></td>
</tr>
<tr>
<td class="pptype" valign="top" colspan="2"><span style="FONT-WEIGHT: bold">Metal Information:</span></td>
</tr>
<tr>
<td class="ppname" valign="top" bgcolor="#e8eff9" colspan="2">Sterling Silver</td>
</tr>
<tr>
<td class="pptype" valign="top" colspan="2"><span style="FONT-WEIGHT: bold">Component Information:</span></td>
</tr>
<tr>
<td class="ppname" valign="top" bgcolor="#e8eff9" colspan="2">Lacing</td>
</tr>
</tbody>
</table>
I would be very grateful if someone can help me with this.:)

gkumar
07-14-2009, 10:52 AM
suspect that you're asking about importing data - therefore, the answer you're looking for is to wrap the whole lot in CDATA TAGS.


So, your new <Description> node of your xml, would look like this :-

<Description>

<![CDATA[

<p>Nestled inside their shells, pearls are almost as sweet as Mothers love.
The pendant may be ordered with with a chain or braclets.
Exclusively from us.</p>
<ul>
<li>sterling-silver pendant with sterling chain </li>
<li>freshwater pearls measure 3 mm </li>
</ul>
<table cellspacing="1" cellpadding="0" width="356" border="0">
<tbody>
<tr>
<td>
<img height="1" alt="" src="../content/images/spacer.gif" width="146" border="0" /></td>
<td>
<img height="1" alt="" src="../content/images/spacer.gif" width="210" border="0" /></td>
</tr>
<tr>
<td align="middle" bgcolor="#e8eff9" colspan="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif"><span style="FONT-WEIGHT: bold">Product Details</span> </span></td>
</tr>
<tr>
<td class="pptype" valign="top" colspan="2"><span style="FONT-WEIGHT: bold">Metal Information:</span></td>
</tr>
<tr>
<td class="ppname" valign="top" bgcolor="#e8eff9" colspan="2">Sterling Silver</td>
</tr>
<tr>
<td class="pptype" valign="top" colspan="2"><span style="FONT-WEIGHT: bold">Component Information:</span></td>
</tr>
<tr>
<td class="ppname" valign="top" bgcolor="#e8eff9" colspan="2">Lacing</td>
</tr>
</tbody>
</table>

]]>

</Description>

gkumar
07-14-2009, 10:54 AM
I suspect that you're asking about importing data - therefore, the answer you're looking for is to wrap the whole lot in CDATA TAGS.


So, your new <Description> node of your xml, would look like this :-


C#/VB.NET Code:

<Description>

<![CDATA[

<p>Nestled inside their shells, pearls are almost as sweet as Mothers love.
The pendant may be ordered with with a chain or braclets.
Exclusively from us.</p>
<ul>
<li>sterling-silver pendant with sterling chain </li>
<li>freshwater pearls measure 3 mm </li>
</ul>
<table cellspacing="1" cellpadding="0" width="356" border="0">
<tbody>
<tr>
<td>
<img height="1" alt="" src="../content/images/spacer.gif" width="146" border="0" /></td>
<td>
<img height="1" alt="" src="../content/images/spacer.gif" width="210" border="0" /></td>
</tr>
<tr>
<td align="middle" bgcolor="#e8eff9" colspan="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif"><span style="FONT-WEIGHT: bold">Product Details</span> </span></td>
</tr>
<tr>
<td class="pptype" valign="top" colspan="2"><span style="FONT-WEIGHT: bold">Metal Information:</span></td>
</tr>
<tr>
<td class="ppname" valign="top" bgcolor="#e8eff9" colspan="2">Sterling Silver</td>
</tr>
<tr>
<td class="pptype" valign="top" colspan="2"><span style="FONT-WEIGHT: bold">Component Information:</span></td>
</tr>
<tr>
<td class="ppname" valign="top" bgcolor="#e8eff9" colspan="2">Lacing</td>
</tr>
</tbody>
</table>

]]>

</Description>

rosetaylor01
07-16-2009, 07:39 AM
question is - how can I pass the following HTML code in the <Description> XML tag a for Product XML package. Currently, I pass the following via XML and it works.
A standard way to do this would be to designate special non-HTML elements in
a namespace. Or, if you find that HTML elements are the exception rather
than the rule, you may wish to use the HTML namespace for them. Either way,
if you put them in different namespaces, your stylesheet will be able to
always copy HTML elements, and do special things with the rest.

Source:
<html xmlns:special="http://foo.bar.com">
<body>
<table>
<tr><td><special:content/></td></tr>
<tr><td><special:content/></td></tr>
</table>
</body>
</html>

Stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:foo="http://foo.bar.com">

<!-- Recursively copy all elements and attributes and their
children... -->
<xsl:template match="*|@*">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()"
</xsl:copy>
</xsl:template>

<!-- ...except for elements in this namespace, which will require special
processing -->
<xsl:template match="foo:*">
<!-- Do special stuff for elements in this namespace -->
</xsl:template>

</xsl:stylesheet>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum