Obviamente mal, y la pregunta no es si esta mal o no. Es ¿por que?, si supiera no preguntaria :O
Incluso lo deje asi:
Código PHP:
$pais = new Pais();
$con = new ConsultasSQL();
$lista = $con->getListaPaises(" ");
$xml = new SimpleXMLElement('<paisGeneral></paisGeneral>');
$xml->addChild('cuerpo');
foreach ($lista as $pais){
$xml->cuerpo->addChild('nombrePais',$pais->getNombrePais());
$xml->cuerpo->addChild('intCantidadMercancia',$pais->getCantidadMercancias());
$xml->cuerpo->addChild('fobItem',$pais->getFobItem());
$xml->cuerpo->addChild('cifItem',$pais->getCifItem());
$xml->cuerpo->addChild('fleteItem',$pais->getFleteItem());
$xml->cuerpo->addChild('seguroItem',$pais->getSeguroItem());
}
@header('Content-type: text/xml');
echo $xml->saveXML('./xml/test.xml');
Lo que devuelve un xml mejor formado, algo asi:
<cuerpo>
<paisGeneral>
<nombrePais>zona franca iquique</nombrePais>
<intCantidadMercancia>420121200</intCantidadMercancia>
<fobItem>451176</fobItem>
<cifItem>3183</cifItem>
<fleteItem>22559</fleteItem>
<seguroItem>9024</seguroItem>
</cuerpo>
</paisGeneral>
Pero sigue mostrando el error apesar de haber creado el archivo.