html in xml

Discussion in 'Perl Misc' started by a, Sep 15, 2009.

  1. a

    a Guest

    Hi,

    I need to contain some html tag, which is the body of an html email, in a
    xml file. I would use XML simple to retrieve the content of the xml file.
    If it is not quoted properly, the xml file cannot be read by xml simple. How
    should i quote the message with html tag?

    Thanks
     
    a, Sep 15, 2009
    #1
    1. Advertising

  2. a

    Bart Lateur Guest

    a wrote:

    >I need to contain some html tag, which is the body of an html email, in a
    >xml file. I would use XML simple to retrieve the content of the xml file.
    >If it is not quoted properly, the xml file cannot be read by xml simple. How
    >should i quote the message with html tag?


    Escape the HTML file when you put it in the XML file as the content of
    an element. That's what most people do.

    --
    Bart.
     
    Bart Lateur, Sep 15, 2009
    #2
    1. Advertising

  3. a

    Guest

    On Tue, 15 Sep 2009 01:23:53 -0700, "a" <> wrote:

    >Hi,
    >
    >I need to contain some html tag, which is the body of an html email, in a
    >xml file. I would use XML simple to retrieve the content of the xml file.
    >If it is not quoted properly, the xml file cannot be read by xml simple. How
    >should i quote the message with html tag?
    >
    >Thanks
    >


    If xml simple uses an xml parser, I would just put it into a CDATA element.
    That way you won't have to escape the html. But I don't know what simple
    does on special elements like CDATA, xml decl's, etc..

    You could always just use an xml parser directly to capture the
    contents of CDATA.
    CDATA is not html so you won't have to worry about nesting.

    Something like below.
    -sln
    -----------------------

    ************************
    xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <doc>
    <![CDATA[

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
    <TITLE>Dear Valued Customer, </TITLE>
    <STYLE>
    <!--
    @page { size: 8.5in 11in; margin-right: 1.25in; margin-top: 1in; margin-bottom: 1in }
    P { margin-bottom: 0.08in; direction: ltr; color: #000000; widows: 2; orphans: 2 }
    P.western { font-family: "Times New Roman", serif; font-size: 12pt; so-language: en-US }
    P.cjk { font-family: "Times New Roman", serif; font-size: 12pt }
    P.ctl { font-family: "Times New Roman", serif; font-size: 12pt; so-language: ar-SA }
    A:link { color: #0000ff }
    -->
    </STYLE>
    </HEAD>
    <BODY LANG="en-US" TEXT="#000000" LINK="#0000ff" DIR="LTR">
    </BODY>
    </HTML>
    ]]>
    </doc>


    ************************
    parsed xml:

    ______________________________

    xmldecl_h _: version = 1.0
    encoding = utf-8
    --------------------
    char _:

    --------------------
    start _: doc
    --------------------
    char _:

    --------------------
    cdata _:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
    <TITLE>Dear Valued Customer, </TITLE>
    <STYLE>
    <!--
    @page { size: 8.5in 11in; margin-right: 1.25in; margin-top: 1in; margin-bottom: 1in }
    P { margin-bottom: 0.08in; direction: ltr; color: #000000; widows: 2; orphans: 2 }
    P.western { font-family: "Times New Roman", serif; font-size: 12pt; so-language: en-US }
    P.cjk { font-family: "Times New Roman", serif; font-size: 12pt }
    P.ctl { font-family: "Times New Roman", serif; font-size: 12pt; so-language: ar-SA }
    A:link { color: #0000ff }
    -->
    </STYLE>
    </HEAD>
    <BODY LANG="en-US" TEXT="#000000" LINK="#0000ff" DIR="LTR">
    </BODY>
    </HTML>

    --------------------
    char _:

    --------------------
    end _: /doc
    --------------------
    ______________________________
    end parse _: 0 errors
    TOTAL SEGMENTS = 7
     
    , Sep 15, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven Cheng[MSFT]

    RE: Convert HTML to XML or Paser HTML

    Steven Cheng[MSFT], Jan 9, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    3,472
    George Ter-Saakov
    Feb 12, 2004
  2. Joerg Jooss

    Re: Convert HTML to XML or Paser HTML

    Joerg Jooss, Jan 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    560
    Joerg Jooss
    Jan 11, 2004
  3. Q.Z
    Replies:
    0
    Views:
    581
  4. Adam Akhtar
    Replies:
    9
    Views:
    546
    Florian Gilcher
    Aug 16, 2008
  5. Erik Wasser
    Replies:
    5
    Views:
    468
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page