05 Sep, 07:15PM in sunny Singapore!

XML encoding issues

Subscribe to XML encoding issues 2 posts

Please Login or Signup to reply.
  • Trcyng's Avatar
    51 posts since Jun '08
    • Hi,

      I am doing a XML file with chinese and korean characters.

      It was fine when it was in English but when inserting the chinese characters, it has errors;

      Warning: SimpleXMLElement::construct() [function.SimpleXMLElement—-construct]: Entity: line 98: parser error : Premature end of data in tag description2 line 98 in C:\Program Files\xampp\htdocs\plaincart\parselangxml.php on line 4

      Warning: SimpleXMLElement::construct() [function.SimpleXMLElement—-construct]: t and in the mean time, pursuing and promoting interest of local food to even mo in C:\Program Files\xampp\htdocs\plaincart\parselangxml.php on line 4

      Fatal error: Uncaught exception ‘Exception’ with message ‘String could not be parsed as XML’ in C:\Program Files\xampp\htdocs\plaincart\parselangxml.php:4 Stack trace: #0 C:\Program Files\xampp\htdocs\plaincart\parselangxml.php(4): SimpleXMLElement->__construct(‘<?xml version=”...&#8217Wink #1 C:\Program Files\xampp\htdocs\plaincart\index.php(4): include(‘C:\Program File…&#8217Wink #2 {main} thrown in C:\Program Files\xampp\htdocs\plaincart\parselangxml.php on line 4


      I know that it has to do with the encoding but upon trying all standards, it remains the same. Anyway, this is my parsexml file;

      <?php

      $xmlFileData = file_get_contents(“lang.xml&#8221Wink;
      $xmlData = new SimpleXMLElement($xmlFileData);

      if ($_COOKIE[‘cookieLanguage’] != ”&#8221Wink {

                              $lang_choice = $_COOKIE['cookieLanguage'];
                              

      }
      else {

                              $lang_choice = "English";
                              

      }

      $i = 0;
      while($xmlData->language[$i]->type != $lang_choice) { $i++;
      } // end foreach

      $lang = $xmlData->language[$i];

      ?>

      Could anyone help me?

  • Moderator
    The only cure for procrastination is a terminal illness.
    LatecomerX's Avatar
    2,069 posts since May '07
    • Once again, change the encoding of the XML file to UTF-8.

      <?xml version="1.0" encoding="utf-8"?>

       

Please Login or Signup to reply.