Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to pass HTML within XML Tags

    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.
    Code:
    <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.
    Code:
    <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.

    Code:
    <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
    Last edited by Alex Vincent; 06-22-2009 at 06:27 AM. Reason: inserting code tags

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,460
    Thanks
    1
    Thanked 23 Times in 21 Posts

    Question

    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.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    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.
    Code:
    <Description><![CDATA[<p>This goes in the Product Description area</p>]]></Description>
    Last edited by Bill Posters; 06-22-2009 at 06:47 AM.

  • #4
    Banned
    Join Date
    Jun 2009
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile How to pass HTML within XML Tags

    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.

  • #5
    Banned
    Join Date
    Jun 2009
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to pass HTML within XML Tags

    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>

  • #6
    Banned
    Join Date
    Jun 2009
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to pass HTML within XML Tags

    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>

  • #7
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •