Archives Home

PHP Fix for New Feature | Archives

March 31, 2010

I’m working on a new feature for the US Flash map that I sell.  I want users to input their data into a web interface, click a button, and have my script create the XML that, combined with my map, visualizes the data for the different states.  I’ll write more about the feature when it is online.

To write the script I needed to be able to use PHP to manipulate the XML file that powers my map.  I decided to use SimpleXML.  It works really nicely, except when you want to work with CDATA.  CDATA is the HTML that users can input into the descriptions for different states.  When I tried to use SimpleXML to write HTML, it would turn my “<”  into  “&lsquo;”.  That was a big problem.

If you’re searching on google to write CDATA using SimpleXML in PHP here is the solution:

It uses the more complicated, but more powerful method of writing to XML, DOM, to write the CDATA without replacing HTML tags.  I don’t totally understand why it works…but it does!  Hope it helps someone.

BTW:  The code screen shot is from Blue Fish Web Development Studio.  It’s free and it’s my code editor of choice!

Home | License | Privacy | Releases | Testimonials | Resources | Documentation | Order Lookup | All Maps | FAQs
Formerly FlashUSAmap.com and FlashWorldMap.com
SimpleMaps.com is a product of Pareto Software, LLC. © 2010-2024.