Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/01/2011, 14:19
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: simplexml_load_string

Podrías ir iterando el arreglo para que vaya creando la estructura con addChild de SimpleXML.

Edito: de esta forma lo puedes hacer
Código PHP:
Ver original
  1. <?php
  2. $array = array(
  3.     'ServicioEntregaResult' => array(
  4.         'ApplicationState' => array(
  5.             'OperacionExitosa' => 1,
  6.             'Novedad' => '-'
  7.         ),
  8.         'Dato' => 123456
  9.     )
  10. );
  11. function convertArr($arr){
  12.     $convert = '';
  13.     foreach($arr as $key => $val){
  14.         $convert .= is_array($val)
  15.             ? '<' . $key . '>' . convertArr($val) . '</' . $key . '>' . PHP_EOL
  16.             : '<' . $key . '>' . $val . '</' . $key . '>' . PHP_EOL;
  17.     }
  18.     return $convert;
  19. }
  20. $xml = convertArr($array);
  21. $fixXml = new SimpleXMLElement($xml);
  22. echo $fixXml->asXML();
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos

Última edición por abimaelrc; 11/01/2011 a las 14:50