Hi
I have an xml file which i am trying to display through a php script, it displays everything fine until i change the contents of the xml file to Arabic letters at which the file does not load.

here is the xml file:

<?xml version="1.0"?> 
  <studentmarks> 
      <listName>name of the student</listName>
      <studentdetalis>
          <studentnumber>555</studentnumber>
          <subjects>
              <physics>55</physics>
              <chemistry>2</chemistry>

          </subjects>
      </studentdetalis>
    
  </studentmarks>

and here is the php script:

<?php 
  $student = "test.xml" ; 
  $xml = @simplexml_load_file($student) or die ("no file loaded") ; 
  $studentlist = $xml->listName ;
  echo "<h1>List: " . $studentlist . "</h1>";
  
  foreach ($xml->studentdetalis as $studentdetalis) {
  echo "<h2>Food group name is " . $studentdetalis->studentnumber . "</h2>" ;

  foreach ($studentdetalis->subjects as $subjects) {
      echo "<br /> physics: " . $subjects->physics ;
	  echo "<br /> chemistry: " . $subjects->chemistry ;
      echo "<br />" ;
  }
  }
  echo "<br />" ;
?>

when I try, for example, to change the word between listname tags to Arabic letters i get the error no file loaded.

What am I doing wrong?

thanks for the link it was helpful. However I face the issue that my website is encoded in windows-1256 (Arabic) while the xml file is encoded in utf-8 (I can not encode the file in Arabic even if I add the encoding tag to it). The problem is when I view my website through the browser I get unknown characters for the xml content, while my website looks fine.

when I change the encoding of the website through the browser the content of the xml file look fine while my website does not.

is there a way to get around this issue?

This article has been dead for over six months. Start a new discussion instead.