homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

Illegal Charcters in XML feed

 9:16 am on Jul 15, 2008 (gmt 0)

I have an XML feed that is based upon text submitted by users, however every so often users submit characters taht are illegal for XML causing the entire feed to choke :(

I need some help in filtering out (brute force replace is ok) these ilegal characters.




 9:22 am on Jul 15, 2008 (gmt 0)

Whatever script you are using to parse the feed is what you need to replace the characters. For example, with PHP you can use str_replace(). I, on the other hand, would run the XML through W3C's validator service to see if it is valid XML before using it--if not then show an alert of some kind.


 2:36 pm on Jul 15, 2008 (gmt 0)

you can either pasteurize the text to remove/replace those characters, or you can wrap them in a special CDATA placenta.

So, for instance:

<title>The Big Book of &lt;XML&gt; &amp; &amp;agrave;cc&amp;eacute;nted char&amp;agrave;ct&amp;egrave;rs</title>


<title><![CDATA[The Big Book of <XML> & àccénted charàctèrs]]></title>

the CDATA is a far better solution


 2:39 pm on Jul 15, 2008 (gmt 0)

FYI regarding CDATA:

Unless you know that the user-entered data is safe, like it's only EVER going to be an integer or alphanumeric string, then treat it as CDATA and encapsulate it accordingly.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / XML Development
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