Les escribo por que estoy generando un scritp el cual contienen varios archivos para crear un sistema de comentarios en php para mandar saludos.
Tengo un archivo flash llamado mensajes.swf
el cual contiene el siguiente codigo.
Código PHP:
// Action script...
// [Action in Frame 1]
function cargarDatos(_indice)
{
var _loc3;
var _loc2;
var _loc4;
var _loc6;
var _loc7;
var _loc5;
var _loc8;
var _loc10;
var _loc11;
var _loc9;
_loc3 = mensajes_xml.firstChild.childNodes[0].firstChild.nodeValue;
_loc2 = mensajes_xml.firstChild.childNodes[1].firstChild.nodeValue;
_loc4 = mensajes_xml.firstChild.childNodes[2].firstChild.nodeValue;
_loc6 = mensajes_xml.firstChild.childNodes[3].firstChild.nodeValue;
_loc7 = mensajes_xml.firstChild.childNodes[4].firstChild.nodeValue;
_loc5 = mensajes_xml.firstChild.childNodes[5].firstChild.nodeValue;
_loc8 = mensajes_xml.firstChild.childNodes[6].firstChild.nodeValue;
_loc10 = mensajes_xml.firstChild.childNodes[7].firstChild.nodeValue;
_loc11 = mensajes_xml.firstChild.childNodes[8].firstChild.nodeValue;
_loc9 = mensajes_xml.firstChild.childNodes[9].firstChild.nodeValue;
_root.usuario1_txt.htmlText = _root.usuario1_txt.htmlText + _loc3;
_root.mensaje1_txt.htmlText = _root.mensaje1_txt.htmlText + _loc2;
_root.usuario2_txt.htmlText = _root.usuario2_txt.htmlText + _loc4;
_root.mensaje2_txt.htmlText = _root.mensaje2_txt.htmlText + _loc6;
_root.usuario3_txt.htmlText = _root.usuario3_txt.htmlText + _loc7;
_root.mensaje3_txt.htmlText = _root.mensaje3_txt.htmlText + _loc5;
_root.usuario4_txt.htmlText = _root.usuario4_txt.htmlText + _loc8;
_root.mensaje4_txt.htmlText = _root.mensaje4_txt.htmlText + _loc10;
_root.usuario5_txt.htmlText = _root.usuario5_txt.htmlText + _loc11;
_root.mensaje5_txt.htmlText = _root.mensaje5_txt.htmlText + _loc9;
} // End of the function
System.useCodepage = true;
var indice;
var mensajes_xml;
indice = 0;
mensajes_xml = new XML();
mensajes_xml.ignoreWhite = true;
mensajes_xml.load("mensajes.xml?nocache=" + Math.random());
mensajes_xml.onLoad = function ()
{
cargarDatos(indice);
};
Este codigo hace que por medio de un archivo FLASH los vaya mostrando.
Tengo otro mas donde este genera el archivo XML para que sea interpretado por el FLASH
Código PHP:
<?php
function creaXML{
/*Seleccionamos los datos de la tabla correspondiente*/
$result=mysql_query("SELECT id, nombre, comentarios FROM miTabla");
/*la variable $fp guardará el identificador del fichero con el que estamos trabajando. El fichero mensajes.xml lo creará en la misma ruta donde se ejecute el script de php.*/
if(!$fp=fopen("mensajes.xml","w+")) echo "No se ha podido abrir el fichero";
else
{
/*Escribo la cabecera del xml
Véase que \r (retorno de carro) en octal es 015 y \n (nueva linea) en octal es 012*/
fwrite($fp,"<?xml version="1.0" encoding=\"ISO-8859-1\"?>\015\012"))
while($row=mysql_fetch_array($result))
{
/*estructura del nodo*/
fwrite($fp,"<mensajes>\015\012
<id>".$row[id]."</id>\015\012
<nombre>".$row[nombre]."</nombre>\015\012
<mensaje1>".$row[comentarios]."</mensaje1>\015\012
</mensajes>");
}
if(!fclose($fp)) echo "No se ha podido cerrar el fichero";
}
?>
He ahi el problema no se como generar para que en el archivo XML me cree un archivo de tipo como el siguiente.
Código PHP:
<?xml version="1.0" encoding="iso-8859-1"?>
<mensajes>
<mensaje1>BIENVENIDOS AL CENTRO DE MENSAJES</mensaje1>
<mensaje2>BIENVENIDOS AL CENTRO DE MENSAJES</mensaje2>
</mensajes>
El problema es que no se como hacer para que me cree automaticamente en el XML mensaje1, mensaje2, mensaje3.
Si alguien me puede ayudar se los voy agradecer muchisimo.
Muchas Gracias!