html in xml

A

a

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
 
B

Bart Lateur

a said:
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.
 
S

sln

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top