On Tue, Jul 29, 2008 at 4:59 PM, Andrew Ballard <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 29, 2008 at 3:52 PM, Thiago H. Pojda <[EMAIL PROTECTED]>
> wrote:
> > That's weird. I just changed it to convert everything to UTF and things
> > appear ok on IE and messy in Firefox. I guess firefox isn't been nice to
> my
> > headers after all. It keeps saying the content is in ISO.
> >
> > Thanks for your hints and your time. I'll move this to firefox list, as
> the
> > XML loads fine in IE (everything set to UTF, even the iconv is
> uncommented).
> >
>
> Did you change the header call too? The header in your original
> example was ISO too:
>
> <snip>
>
> Andrew
>
>
Here's the new code. Loads fine in other viewers, but firefox still think
it's a ISO file and loads accented chars incorrecly.
<?php
header('Content-type: text/xml; charset = UTF-8');
$unidades = listarUnidadesSetor(58,1);
$doc = new DOMDocument("1.0", 'UTF-8');
$doc->formatOutput = true;
$xml = $doc->createElement( "unidades" );
$doc->appendChild( $xml );
foreach ($unidades as $unidade)
{
$valores = get_object_vars($unidade);
// var_dump($atributos);
$unidade = $doc->createElement( "unidade" );
foreach ($valores as $atributo=>$valor){
$valor = iconv('ISO-8859-1','UTF-8',$valor);
$node = $doc->createElement( $atributo );
$node->appendChild(
$doc->createTextNode( $valor )
);
$unidade->appendChild( $node );
}
$xml->appendChild( $unidade );
}
$doc->appendChild( $xml );
echo $doc->saveXML();
?>
--
Thiago Henrique Pojda