Click to See Complete Forum and Search --> : Xml IE enconding


sandro27
01-04-2009, 08:50 PM
Hi,

I am having a situation with a google map page (http://www.floripaimages.com/maps/lodging.php) that works on FF and chrome but not in IE. It must show the markers on IE but it is not showing, it gives me an error.

I found that the problem was related to enconding and I could half fix it. If I run the code bellow on IE it gives me the right XML output:

<?php
require("phpsqlajax_dbinfo.php");

function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','&lt;',$htmlStr);
$xmlStr=str_replace('>','&gt;',$xmlStr);
$xmlStr=str_replace('"','&quot;',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&amp;',$xmlStr);

return $xmlStr;
}

// Opens a connection to a MySQL server
$connection=mysql_connect ("floripai.ipowermysql.com", $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the markers table
$query = "SELECT * FROM markers WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}

// Start XML file, echo parent node

echo '<?xml version="1.0" encoding="iso-8859-2"?>';


echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
}

// End XML file
echo '</markers>';

?>

But when I run the page (http://www.floripaimages.com/maps/lodging.php) which calls the script above, it gives me an error.

How can I fix it to run on IE ?

Appreciate any help

Thanks

Sandro

Stephen Philbin
01-11-2009, 07:49 AM
If you think it's an encoding problem, then you should probably specify it in the HTTP header.

Currently, your Content-Type header just says "text/html". Perhaps you should have it say 'text/html; charset="UTF-8"'.

I can't really see how this is related to XML, though. As far as I can see, it's just HTML and Javascript. Would you like me to move the thread to one of those forums? It would get a lot more eyes and so hopefully a lot more in the way of helpful suggestions.