Vous pouvez utiliser un XMLWriter pour assurer un encodage correct et autres.
<?php
$stmt = new Dummy;
$stmt->bind_result($foo);
$xml = new XMLWriter();
$xml->openURI('php://output');
$xml->setIndent(true);
$xml->startDocument();
$xml->startElement("xml");
while ( $stmt->fetch() ) {
$xml->startElement("RECORD");
$xml->writeElement('FOO', $foo);
$xml->endElement(); // RECORD
}
$xml->endElement(); // xml
class Dummy {
public function bind_result(&$var) {
$this->var = &$var;
}
public function fetch() {
static $arr = array('Barnes & Noble', 'Barnum & Bailey', "Buy'n'Large");
if ( current($arr) ) {
$this->var = current($arr);
next($arr);
return true;
}
return false;
}
}