Ver Mensaje Individual
  #6 (permalink)  
Antiguo 17/07/2011, 12:00
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, 8 meses
Puntos: 1517
Respuesta: como modificar un xml desde php

Para crear un archivo XML con SimpleXML o DOM es bien simple. Te doy un ejemplo con SimpleXML
Código PHP:
Ver original
  1. <?php
  2. $xml = new SimpleXMLElement("<foo></foo>");
  3. $xml->addAttribute('fooattr', 'value of fooattr');
  4.  
  5. $bar = $xml->addChild('bar');
  6. $bar->addAttribute('barattr', 'value of barattr');
  7.  
  8. $baz = $xml->addChild('baz');
  9.  
  10. $candy = $baz->addChild('candy', 'value of candy');
  11. $candy->addAttribute('candyattr', 'value of candyattr');
  12.  
  13. $fruits = $baz->addChild('fruits', 'value of fruits');
  14. $fruits->addAttribute('fruitsattr', 'value of fruitsattr');
  15.  
  16. $vegetable = $baz->addChild('vegetable', 'value of vegetable');
  17. $vegetable->addAttribute('vegetableattr', 'value of vegetableattr');
  18.  
  19. header('Content-type: text/xml; charset=utf-8');
  20. echo $xml->asXML();
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos