Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP SimpleXML - Adding Text from forms to XML



12:48 am on Sep 18, 2011 (gmt 0)

5+ Year Member

Hi all,

I'm trying to find a tried and tested method of adding user generated text into XML. An example would be a user types some text into a text area, posts it to a php page, then I check the text for html characters and add it to the XML.

My issue, is that the XML is breaking because some non allowed characters are getting through. I have tried:

  • strip_tags - to remove html[/li]
  • htmlspecialchars - to convert non xml approved characters to acceptable character[/li]

I would like to ideally keep the html in the text if possible. Does anyone have a good method of processing text for addition to XML?



11:33 am on Sep 18, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

Have you tried wrapping the user defined content in <[CDATA[ ]]> tags?

<xml_element_name><[CDATA[user defined content]]></xml_element_name>

Featured Threads

Hot Threads This Week

Hot Threads This Month