Skip to content
Browse files

now utf-8 encoding xml string before passing it into simplxml_load_st…

…ring to avoid parsing errors if string isn't properly encoded
  • Loading branch information...
1 parent 4887e99 commit 2478fe366e49729b241bdaf9f84dcffb46262d59 erik committed Dec 14, 2009
Showing with 12 additions and 3 deletions.
  1. +4 −1 basic.php
  2. +4 −1 entertainment.php
  3. +4 −1 standard.php
View
5 basic.php
@@ -16,8 +16,11 @@
$xmlString = curl_exec($ch);
curl_close($ch);
+//ensure string is utf-8 encoded for simplexml_load_string()
+$utf8String = utf8_encode($xmlString);
+
//parse xml
-$feed = simplexml_load_string($xmlString);
+$feed = simplexml_load_string($utf8String);
//format data & set default values to keep template uncluttered
$data = array(
View
5 entertainment.php
@@ -16,8 +16,11 @@
$xmlString = curl_exec($ch);
curl_close($ch);
+//ensure string is utf-8 encoded for simplexml_load_string()
+$utf8String = utf8_encode($xmlString);
+
//parse xml
-$feed = simplexml_load_string($xmlString);
+$feed = simplexml_load_string($utf8String);
//format data & set default values to keep template uncluttered
$data = array(
View
5 standard.php
@@ -12,8 +12,11 @@
$xmlString = curl_exec($ch);
curl_close($ch);
+//ensure string is utf-8 encoded for simplexml_load_string()
+$utf8String = utf8_encode($xmlString);
+
//parse xml
-$feed = simplexml_load_string($xmlString);
+$feed = simplexml_load_string($utf8String);
//format data & set default values to keep template uncluttered
$data = array(

0 comments on commit 2478fe3

Please sign in to comment.
Something went wrong with that request. Please try again.