Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I store html page in a xml file?

Tags:

html

c#

email

xml

I have a small application written in c# as a console app that I want to use to send an email. I was planning on storing the email inside an xml file along with other information that the message will need like a subject. However there seems to be a problem because the XML file doesnt like </br> characters.

Im wondering what I should do in order to store a html email do I just have to keeo the body html in a seperate html file and then read each line into a StreamReader object?

like image 298
Exitos Avatar asked May 12 '11 12:05

Exitos


2 Answers

The easiest way would be to store the HTML content in a CDATA section:

<mail>
  <subject>Test</subject>
  <body>
    <![CDATA[
      <html>
        ...
      </html>
     ]]>
  </body>
</mail>
like image 58
Daniel Hilgarth Avatar answered Sep 19 '22 03:09

Daniel Hilgarth


Use a CDATA section, that will contain your email HTML code :

<?xml version="1.0"?>
<myDocument>
  <email>
    <![CDATA[
        <html>
          <head><title>My title</title></head>
          <body><p>Hello world</p></body>
        </html>
    ]]>
  </email>
</myDocument>
like image 31
mathieu Avatar answered Sep 20 '22 03:09

mathieu