homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

PHP SimpleXML - Adding Text from forms to XML

5+ Year Member

Msg#: 4363900 posted 12:48 am on Sep 18, 2011 (gmt 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?




WebmasterWorld Senior Member

Msg#: 4363900 posted 11:33 am on Sep 18, 2011 (gmt 0)

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

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved