I have this code:
html code:
<script>
function loadXMLDoc(filename)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",filename,false);
xhttp.send();
return xhttp.responseXML;
}
var xmlDoc = loadXMLDoc('users.xml');
var x = xmlDoc.getElementsByTagName('usr');
document.write(x.length);
</script>
xml code:
<?xml version="1.0" encoding="utf-8"?>
<users xmlns="http://localhost" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost users.xsd">
<usr><age>25</age><country>الاردن</country></usr>
<usr><age>30</age><country>مصر</country></usr>
</users>
And I want to include the html code in another html document like this:
html code:
<!DOCTYPE html unicode="utf-8">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
include 'users.html';
?>
</body>
</html>
the output of the javascript code is: 0 while it should be 2 and if I replace the arabic text in the xml document with english text the output become 2.
Why is the arabic text breaking the code?