Hello!

This is my first run at XML and it seems to be working well, aside from this 
particular problem.

We have a SWF file that references an XML doc stored in a table in one of our 
databases.  The SWF pulls everything just fine.

However, when I'm setting new variables and re-updating the XML, no matter 
what, it automatically escapes all HTML.


For example, here is a similar example of what the XML looks like when it goes 
into the database the first time:


<cfsavecontent variable="myXML">
<?xml version="1.0" encoding="UTF-8"?>
<car>
  <price>$4,000</price>
  <adbody><!CDATA[[Wow <b>What a deal!</b> <ul><li>blah</li></ul>Just 
Wow!]]></adbody>
</car>
</cfsavecontent>

<cfquery...>
INSERT INTO someTable(blah)
VALUES(<cfqueryparam cfsqltype="cf_sql_varchar" value="#myXML#">)
</cfquery>




Now when I initially build the XML like that, it will pass in any and all html 
I give it.  It inserts like it should.


But on subsequent updates, I update the values like such:


<cfquery>select xml value from table</cfquery>

<cfxml variable="xmlVar">#trim(theQuery'sXMLValue)#</cfxml>

<cfset xmlVar = xmlParse(trim(xmlVar))>


****  HERE IS THE PROBLEM  ****

<cfset xmlVar.car.adbody.XmlText = "#New Value From Form Goes Here#">






After all of the cfsets, I do an update on the table and submit #xmlVar# again.


Everything else works and saves and does what it should.

But for some reason, I can confirm that:

1) The new form value holds unescaped html
2) Even referencing "xmlVar.car.adbody.XmlText" shows that variable holds the 
unescaped html

And yet, when I look up that row in MySQL, it shows ESCAPED html.




I dug a little further and found that:

xmlVar.car.adbody.XmlText = UNESCAPED HTML (correct)

xmlVar itself = ESCAPED HTML (incorrect)



So for some reason when I'm setting a value in the XML, it auto-escapes the 
HTML.


Is there a better way to set XML variables?  Building the tree the same way 
it's done on creation isn't as easy because not all of the info comes across in 
a single form submission.


This way works fine, except when it comes to HTML.  I've searched and searched 
and have not yet found a function that will help me keep it intact.  CDATA lets 
it store and display correctly, but even the CDATA html gets escaped rendering 
it useless =/ 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:299011
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to