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)

Junior Member

5+ Year Member

joined:Mar 20, 2008
posts: 172
votes: 0

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 Sept 18, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
votes: 0

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

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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members