I have two pages, one calls the other with a XMLHttpRequest.
The first page calls and then receives the XML text which appears to be well formed.
All is good until I hit the getElementsByTagName .
The page then abruptly stops with no clues as to why.
Please help.
and the following page which produces the XML text without problem.
<?php $con = mysqli_connect(ID and password, etc); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";$root_element = “main_users”;
$xml .= “<$root_element>”;
//mysqli_select_db($con,“ajax_demo”);
$sql=“SELECT * FROM user ;”;
$result = mysqli_query($con,$sql);
$num = $result->num_rows;
if($num>0)
{
while($result_array = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
$xml .= “”;
//loop through each key,value pair in row
foreach($result_array as $key => $value)
{
//$key holds the table column name
$xml .= "<$key>";
//embed the SQL data in a CDATA element to avoid XML entity issues
$xml .= "<![CDATA[$value]]>";
//and close the element
$xml .= "</$key>";
}
$xml.="</users>";
}
}
mysqli_close($con);
//close the root element
$xml .= “</$root_element>”;
//send the xml header to the browser
header (“Content-Type:text/xml”);
//output the XML data
echo $xml;
?>