Foros del Web » Programando para Internet » PHP »

como guardar con xml?

Estas en el tema de como guardar con xml? en el foro de PHP en Foros del Web. <? header("Content-type: text/xml"); //los arrays se podrían alimentar //con datos extraidos de una base de datos echo '<?xml version="1.0"?>'; echo '<album canvasWidth="980" canvasHeight="398" borderRadius="0" controlXpos="880" ...
  #1 (permalink)  
Antiguo 04/06/2009, 02:30
 
Fecha de Ingreso: mayo-2009
Mensajes: 9
Antigüedad: 14 años, 10 meses
Puntos: 0
como guardar con xml?

<?
header("Content-type: text/xml");
//los arrays se podrían alimentar
//con datos extraidos de una base de datos
echo '<?xml version="1.0"?>';
echo '<album
canvasWidth="980"
canvasHeight="398"
borderRadius="0"
controlXpos="880"
controlYpos="350"
controlAlpha="50"
controlColor="0xffffff"
btColor="0xE4E4E4"
symbolPrevColor="0x336699"
symbolNextColor="0x336699"
symbolPlayColor="0x336699"
symbolPauseColor="0x336699"
transitionDelay="7"
>';
echo "\n";
$pos = 0;
foreach ($_GET['lista2'] as $valor) {
echo '<item';
echo "\n";
echo 'imgPath="';
echo $valor;
echo '"';
echo "\n";
echo 'imageUrl=""';
echo "\n";
echo 'imageUrltarget="_blank"';
echo "\n";
echo '/>';
echo "\n";
$pos++;
}
echo '</album>';
?>
Este codigo en php me genera esto
<album canvasWidth="980" canvasHeight="398" borderRadius="0" controlXpos="880" controlYpos="350" controlAlpha="50" controlColor="0xffffff" btColor="0xE4E4E4" symbolPrevColor="0x336699" symbolNextColor="0x336699" symbolPlayColor="0x336699" symbolPauseColor="0x336699" transitionDelay="7">
<item imgPath="imagenes/habitaciones/0.jpg " imageUrl="" imageUrltarget="_blank"/>
<item imgPath="imagenes/habitaciones/1.jpg " imageUrl="" imageUrltarget="_blank"/>
<item imgPath="imagenes/habitaciones/2.jpg " imageUrl="" imageUrltarget="_blank"/>
<item imgPath="imagenes/habitaciones/3.jpg " imageUrl="" imageUrltarget="_blank"/>
<item imgPath="imagenes/habitaciones/4.jpg " imageUrl="" imageUrltarget="_blank"/>
<item imgPath="imagenes/habitaciones/5.jpg " imageUrl="" imageUrltarget="_blank"/>
<item imgPath="imagenes/habitaciones/3.jpg" imageUrl="" imageUrltarget="_blank"/>
<item imgPath="imagenes/habitaciones/0.jpg" imageUrl="" imageUrltarget="_blank"/>
</album>
como hago para guardarlo como album.xml
  #2 (permalink)  
Antiguo 04/06/2009, 03:42
Avatar de danielrivas  
Fecha de Ingreso: noviembre-2007
Ubicación: Preprocessing
Mensajes: 275
Antigüedad: 16 años, 5 meses
Puntos: 6
Respuesta: como guardar con xml?

Almacena todo en una variable $buffer y luego inserta este codigo:

Código PHP:
$name_file="nombredearchivo.xml";
$file=fopen($name_file,"w+");
fwrite ($file,$buffer);
fclose($file); 
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:29.