NLCJ Posted May 10, 2010 Share Posted May 10, 2010 Hello, We get an array from another site, and we convert it to XML for further use. The problem is that special characters result in errors at XML (especially Internet Explorer...) so we have to filter them out, and replace them. This might be a noobish attempt, but I did: $resultsuncensored = $resp->value(); $e = array("é", "ë", "ê", "è"); $resultse = str_replace($e, "e", $resultsuncensored); $resultsen = str_replace("&", "en", $resultse); $a = array("à", "á", "â", "ã", "ä"); $resultsa = str_replace($a, "a", $resultsen); $results = str_replace("ç", "c", $resultsa); But no characters get replaced! How can I solve this / what am I doing wrong? Regards, Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted May 10, 2010 Share Posted May 10, 2010 The most likely cause for the Strange characters would be content encoding. How are you getting this array? Through a HTTP Request? If you are you most likely to to use htmlentities() to encode the special characters. Also, why would these characters break your XML code? If you can provide us with that information we may not need to replace any data. -cb- Quote Link to comment Share on other sites More sharing options...
NLCJ Posted May 10, 2010 Author Share Posted May 10, 2010 I'll look up how I get it parsed to my script. But this is the error I get with XML when it has to say something like: à This page contains the following errors: error on line 34 at column 10: Encoding error Below is a rendering of the page up to the first error. Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted May 10, 2010 Share Posted May 10, 2010 I'll look up how I get it parsed to my script. But this is the error I get with XML when it has to say something like: à This page contains the following errors: error on line 34 at column 10: Encoding error Below is a rendering of the page up to the first error. Is that from an XML function? Or are you displaying that to a browser? -cb- Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.