Hi, Friday, October 4, 2002, 10:14:31 PM, you wrote: DÖJ> <?php DÖJ> header("Content-Type: application/xml"); DÖJ> //query database records DÖJ> $connection = mysql_connect("localhost", "user", "pass") or die("can't connect"); DÖJ> mysql_select_db("webbish"); DÖJ> $query = "SELECT id, title, artist FROM xmldb"; DÖJ> $result = mysql_query($query); DÖJ> if(mysql_num_rows($result) > 0){ DÖJ> //Create DomDocument DÖJ> $doc = new_xmldoc("1.0"); DÖJ> //Add root note DÖJ> $root = $doc->add_root("cds"); DÖJ> //Iterate through result set DÖJ> while(list($id, $title, $artist) = mysql_fetch_row($result)){ DÖJ> //create item node DÖJ> $record = $root->new_child("cd", ""); DÖJ> $record->set_attribute("id", $id); DÖJ> //Attach title and artist as children of item node DÖJ> $record->new_child("title", $title); DÖJ> $record->new_child("artist", $artist); DÖJ> } DÖJ> echo $doc->dumpmem(); DÖJ> } DÖJ> ?> DÖJ> makes a xml doc that looks like this: DÖJ> <?xml version="1.0" ?> DÖJ> - <cds> DÖJ> - <cd id="1"> DÖJ> <title>sdfsdfsdf</title> DÖJ> <artist>ssdfsdf</artist> DÖJ> </cd> DÖJ> - <cd id="2"> DÖJ> <title>asdf</title> DÖJ> <artist>asdf</artist> DÖJ> </cd> DÖJ> - <cd id="3"> DÖJ> <title>sdfasdf</title> DÖJ> <artist>?</artist> DÖJ> </cd> DÖJ> </cds> DÖJ> But I need to modify this script so that I can set the encoding of the xml document to ISO-8859-1 so it would look like this: DÖJ> <?xml version="1.0" encoding=”iso-8859-1” ?> DÖJ> - <cds> DÖJ> - <cd id="1"> DÖJ> <title>sdfsdfsdf</title> DÖJ> <artist>ssdfsdf</artist> DÖJ> </cd> DÖJ> - <cd id="2"> DÖJ> <title>asdf</title> DÖJ> <artist>asdf</artist> DÖJ> </cd> DÖJ> - <cd id="3"> DÖJ> <title>sdfasdf</title> DÖJ> <artist>?</artist> DÖJ> </cd> DÖJ> </cds> DÖJ> Any Ideas how to do this? I’ve been searching the net for solutions without any results. DÖJ> Thanks David One way to force it: <? ob_start(); echo '<?xml version="1.0" encoding="iso-8859-1"?><cds/>'; $buffer = ob_get_contents(); ob_end_clean(); $dom = domxml_open_mem($buffer); echo '<pre>'; echo htmlentities($dom->dump_mem(true)); echo '</pre>'; ?>
-- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php