<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: How to strip invalid XML characters</title>
	<atom:link href="http://benjchristensen.com/2008/02/07/how-to-strip-invalid-xml-characters/feed/" rel="self" type="application/rss+xml" />
	<link>http://benjchristensen.com/2008/02/07/how-to-strip-invalid-xml-characters/</link>
	<description>Software Development and Other Random Stuff</description>
	<lastBuildDate>Mon, 06 Sep 2010 12:52:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Antonio Lagnada</title>
		<link>http://benjchristensen.com/2008/02/07/how-to-strip-invalid-xml-characters/#comment-274</link>
		<dc:creator>Antonio Lagnada</dc:creator>
		<pubDate>Wed, 18 Mar 2009 19:48:55 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=54#comment-274</guid>
		<description>String str = &quot;contains invalid chars&quot;;
String stripped = str.replaceAll(&quot;[^\\u0009\\u000a\\u000d\\u0020-\\ud7ff\\e0000-\\ufffd]&quot;, &quot;&quot;)</description>
		<content:encoded><![CDATA[<p>String str = &#8220;contains invalid chars&#8221;;<br />
String stripped = str.replaceAll(&#8220;[^\\u0009\\u000a\\u000d\\u0020-\\ud7ff\\e0000-\\ufffd]&#8220;, &#8220;&#8221;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Christensen</title>
		<link>http://benjchristensen.com/2008/02/07/how-to-strip-invalid-xml-characters/#comment-256</link>
		<dc:creator>Ben Christensen</dc:creator>
		<pubDate>Sun, 17 Aug 2008 01:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=54#comment-256</guid>
		<description>The original is Java code. Thank you for the code you provided!</description>
		<content:encoded><![CDATA[<p>The original is Java code. Thank you for the code you provided!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anthony</title>
		<link>http://benjchristensen.com/2008/02/07/how-to-strip-invalid-xml-characters/#comment-255</link>
		<dc:creator>anthony</dc:creator>
		<pubDate>Sat, 16 Aug 2008 23:52:51 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=54#comment-255</guid>
		<description>there is something broken about this comment posting script, that code, is _not_ what I posted ;)</description>
		<content:encoded><![CDATA[<p>there is something broken about this comment posting script, that code, is _not_ what I posted <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anthony</title>
		<link>http://benjchristensen.com/2008/02/07/how-to-strip-invalid-xml-characters/#comment-254</link>
		<dc:creator>anthony</dc:creator>
		<pubDate>Sat, 16 Aug 2008 23:51:24 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=54#comment-254</guid>
		<description>I&#039;ll try one more time, cut my post short last time, if it doesn&#039;t work this time... oh well.

function strip_invalid_xml_chars2( &amp;$in )
{
	$out = &quot;&quot;;	
	$length = strlen($in);
	for ( $i = 0; $i = 0x20 &amp;&amp; $current = 0xE000 &amp;&amp; $current = 0x10000 &amp;&amp; $current &lt;= 0x10FFFF):
				// valid so leave &quot;as is&quot;
				break;
			default:
				// invalid, so we set this char to a space
				$in[$i] = &quot; &quot;; 
			break;
		}	
	}
	// NOTE: doesn&#039;t return a value as we worked purely on 
	// the string passed by reference, so don&#039;t try catching a return value	
}</description>
		<content:encoded><![CDATA[<p>I&#8217;ll try one more time, cut my post short last time, if it doesn&#8217;t work this time&#8230; oh well.</p>
<p>function strip_invalid_xml_chars2( &amp;$in )<br />
{<br />
	$out = &#8220;&#8221;;<br />
	$length = strlen($in);<br />
	for ( $i = 0; $i = 0&#215;20 &amp;&amp; $current = 0xE000 &amp;&amp; $current = 0&#215;10000 &amp;&amp; $current &lt;= 0x10FFFF):<br />
				// valid so leave &#8220;as is&#8221;<br />
				break;<br />
			default:<br />
				// invalid, so we set this char to a space<br />
				$in[$i] = &#8221; &#8220;;<br />
			break;<br />
		}<br />
	}<br />
	// NOTE: doesn&#8217;t return a value as we worked purely on<br />
	// the string passed by reference, so don&#8217;t try catching a return value<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anthony</title>
		<link>http://benjchristensen.com/2008/02/07/how-to-strip-invalid-xml-characters/#comment-253</link>
		<dc:creator>anthony</dc:creator>
		<pubDate>Sat, 16 Aug 2008 23:49:15 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=54#comment-253</guid>
		<description>I assume that comment was a PHP version, so you want something like this:
&lt;?php
/**
* Strip bad xml chars
* @author phpzone
* @param string $in String passed by reference
* phpzone.co.uk
*/
function strip_invalid_xml_chars2( &amp;$in )
{
	$out = &quot;&quot;;	
	$length = strlen($in);
	for ( $i = 0; $i = 0x20 &amp;&amp; $current = 0xE000 &amp;&amp; $current = 0x10000 &amp;&amp; $current </description>
		<content:encoded><![CDATA[<p>I assume that comment was a PHP version, so you want something like this:<br />
&lt;?php<br />
/**<br />
* Strip bad xml chars<br />
* @author phpzone<br />
* @param string $in String passed by reference<br />
* phpzone.co.uk<br />
*/<br />
function strip_invalid_xml_chars2( &amp;$in )<br />
{<br />
	$out = &#8220;&#8221;;<br />
	$length = strlen($in);<br />
	for ( $i = 0; $i = 0&#215;20 &amp;&amp; $current = 0xE000 &amp;&amp; $current = 0&#215;10000 &amp;&amp; $current</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ransom</title>
		<link>http://benjchristensen.com/2008/02/07/how-to-strip-invalid-xml-characters/#comment-244</link>
		<dc:creator>ransom</dc:creator>
		<pubDate>Wed, 04 Jun 2008 18:11:16 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=54#comment-244</guid>
		<description>/**
* Strip bad xml chars 
* @author james ransom 2008
* yuku.com
*/
function strip_invalid_xml_chars2( $in )
{

$out = &quot;&quot;;

$length = strlen($in);

for ( $i = 0; $i = 0x20)
 &amp;&amp; ($current = 0xE000) &amp;&amp; 
($current = 0x10000) &amp;&amp; ($current &lt;= 0x10FFFF)))
{
        $out .= chr($current);
}
else
{
        $out .= &quot; &quot;;
}


}

return $out;


}</description>
		<content:encoded><![CDATA[<p>/**<br />
* Strip bad xml chars<br />
* @author james ransom 2008<br />
* yuku.com<br />
*/<br />
function strip_invalid_xml_chars2( $in )<br />
{</p>
<p>$out = &#8220;&#8221;;</p>
<p>$length = strlen($in);</p>
<p>for ( $i = 0; $i = 0&#215;20)<br />
 &amp;&amp; ($current = 0xE000) &amp;&amp;<br />
($current = 0&#215;10000) &amp;&amp; ($current &lt;= 0x10FFFF)))<br />
{<br />
        $out .= chr($current);<br />
}<br />
else<br />
{<br />
        $out .= &#8221; &#8220;;<br />
}</p>
<p>}</p>
<p>return $out;</p>
<p>}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
