Hi guys
I'm writing a small content management tool for a websites news section. On
one screen I have a textarea where the users can enter newsupdates with HTML
tags. The problem is that the HTML tags are automatically escaped, < will be
converted to < and so on. I'm desperate here guys as I'm facing a dead
line. I'm not an expert in XML at all.
Well anyways here's the code, if you have any questions please send me an
email, the variables 'Title' and 'Details' may contain HTML tags:
var Title = String ( Request.Form("title") ) ;
var Details = String ( Request.Form("details") ) ;
var xmlDoc = Server.CreateObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.validateOnParse="true";
xmlDoc.load(Server.MapPath("news.xml"));
if(xmlDoc.parseError.errorCode==0)
{
var xsl = new ActiveXObject("Microsoft.XMLDOM");
xsl.async = false;
xsl.load("news.xsl");
nodes = xmlDoc.documentElement.childNodes;
nodes.item ( 0 ).setAttribute ( "DATE" , Date ( ) ) ;
news = nodes.item ( 0 ).childNodes;
news.item ( 0 ).text = Title ;
news.item ( 1 ).text = Details ;
xmlDoc.save ( Server.MapPath ( "news.xml" ) ) ;
Response.redirect ( "main.asp#news" ) ;
...Quote:}
...
News.xml looks like this:
<?xml version="1.0"?>
<!DOCTYPE NEWSES SYSTEM "news.dtd">
<NEWSES>
<NEWS DATE="Thu May 31 17:33:39 2001">
<TITLE>NEWS FLASH!!</TITLE>
<DETAILS>Dit is een test op Homer</DETAILS>
</NEWS>
</NEWSES>
News.dtd looks like:
<!ELEMENT NEWSES (NEWS)>
<!ELEMENT NEWS (TITLE,DETAILS)>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT DETAILS (#PCDATA)>
<!ATTLIST NEWS DATE CDATA #REQUIRED>
I appreciate any help.
Gabriel Lozano-Morn
Software Engineer
Harte-Hanks CRM Services Belgium