And my new_phpsqlajax_genxml.php looks like :

<?php ob_start(); ?>
<? echo "<?xml version='1.0' encoding='utf-8'>"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">



<? require("phpsqlajax_dbinfo.php");

// Start XML file, create parent node
$doc = new DOMDocument("1.0");
$node = $doc->createElement("markers");
$parnode = $doc->appendChild($node);

// Opens a connection to a mySQL server
$connection=mysql_connect ('mysql.gigahost.dk', $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 markers1 WHERE 1";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}



header("Content-Type: text/xml; charset=utf-8");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date already
passed

// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){

  // ADD TO XML DOCUMENT NODE
  $node = $doc->createElement("marker");
  $newnode = $parnode->appendChild($node);

  // use php utf8_encode() function to encode special characters
   $name=htmlentities($row['name']);
   $name=utf8_encode($name);

   $address=htmlentities($row['address']);
   $address=utf8_encode($address);

  $newnode->setAttribute("name", $name);
  $newnode->setAttribute("address", $address);
  $newnode->setAttribute("lat", $row['lat']);
  $newnode->setAttribute("lng", $row['lng']);
  $newnode->setAttribute("type", $row['type']);
}

$xmlfile = $doc->saveHTML();
echo $xmlfile;
ob_end_flush();
?>




On 28 Sep., 11:27, komsi <[EMAIL PROTECTED]> wrote:
> I have now done these things :
>
> (1) You have danish characters you want to send to your browser via
> XML.
> This is possible using UTF-8 encoding.
> First make sure everyone knows you want to use UTF-8 in your XML
> output.
> You need something in your PHP like -
>     header("Content-Type: text/xml; charset=utf-8");
> This will tell the browser what character encoding to expect.
>
> Then to encode the characters from your database, use something in
> your PHP code like -
>   $address=utf8_encode($address);
> to take care of the danish characters.
>
> (2) Something that was pointed out to you ages ago, was the lack of a
> header on your XML.
> If you ever added it, you took it out again somewhere.
> Try validating your XMLhttp://www.micmus.dk/phpsqlajax_genxml.phpat
> -
>    http://www.validome.org/validate
> And notice that it fails because of missing doctype.
> Notice also that it guesses your character encoding as US-ASCII
>
> You want something like this (called a doctype declaration) at the
> top
> of your XML file -
> echo "<?xml version='1.0' encoding='utf-8'>";
> Notice that it tells the browser's XML parser to expect UTF-8
> encoding.
>
> But still it fails :-(  here :http://www.micmus.dk/new_phpsqlajax_genxml.php
>
> On 28 Sep., 03:31, Rossko <[EMAIL PROTECTED]> wrote:
>
>
>
> > > But what can i do about it ??
>
> > Go back a step and work out what you're trying to.
>
> > (1) You have danish characters you want to send to your browser via
> > XML.
> > This is possible using UTF-8 encoding.
> > First make sure everyone knows you want to use UTF-8 in your XML
> > output.
> > You need something in your PHP like -
> >     header("Content-Type: text/xml; charset=utf-8");
> > This will tell the browser what character encoding to expect.
>
> > Then to encode the characters from your database, use something in
> > your PHP code like -
> >   $address=utf8_encode($address);
> > to take care of the danish characters.
>
> > (2) Something that was pointed out to you ages ago, was the lack of a
> > header on your XML.
> > If you ever added it, you took it out again somewhere.
> > Try validating your XMLhttp://www.micmus.dk/phpsqlajax_genxml.phpat
> > -
> >    http://www.validome.org/validate
> > And notice that it fails because of missing doctype.
> > Notice also that it guesses your character encoding as US-ASCII
>
> > You want something like this (called a doctype declaration) at the top
> > of your XML file -
> > echo "<?xml version='1.0' encoding='utf-8'>";
> > Notice that it tells the browser's XML parser to expect UTF-8
> > encoding.
>
> > -------------
> > Get that working properly before you move on to the next step
> > --------------
>
> > (2)  As completely seperate business, you want to include HTML in your
> > XML data.
> > This is possible using 'entity encoding', so that & < > and so on
> > aren't misunderstood by the XML parser in the browser.
> > You want something in your PHP code like -
> > $address=htmlentities($address, ENT_QUOTES);
> > which will produce &amp; &lt; &gt; &apos; and so on.
> > This will pass through XML without upsetting the parser, but when
> > rendered on-screen the browser should turn them back into & < > etc.
>
> > You'll want to do that after the UTF-8 encoding.
>
> > good luck, Ross K
>
> > > On 27 Sep., 22:37, Rossko <[EMAIL PROTECTED]> wrote:
>
> > > > > <IMG  class=IMG1 SRC=arrows_trans.gif> <a href="http://www.micmus.dk/
> > > > > udvidsoeg.php?map=map&maal=Østrig&afr=1215813600&hjem=1226703600"
> > > > > class=link15>Se Crab Pot ø æ å</a>
>
> > > > Your <IMG> tag is broken - no quotemarks ??
>
> > > > cheers, Ross K- Hide quoted text -
>
> > > - Show quoted text -- Skjul tekst i anførselstegn -
>
> > - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to