El tema es el siguiente, cargo un xml externo con as3, lo modifico, lo envio a php y este lo sobreescribe en el servidor. Si embargo, el php me crea unos backslash delante de todas las comillas del xml dejándolo inutulizable.
Aca esta un sustrato del as para ver si alguien sabe como solucionar este problema
Código ActionScript :
import flash.events.MouseEvent; flash.events.KeyboardEvent; import flash.display.Sprite; import flash.net.URLRequest; import flash.net.URLVariables; import flash.net.sendToURL; // Crear menu de modos ---------------------------------- var modoXML:XML; var XMLRuta:String = "xmls/modo.xml"; var XMLlamado:URLRequest = new URLRequest(XMLRuta); var XMLCargador:URLLoader = new URLLoader(XMLlamado); XMLCargador.addEventListener(Event.COMPLETE, XMLCargado); function XMLCargado(e:Event):void { modoXML = new XML(e.target.data); montarmenu1(); } function montarmenu1():void { var boton:ElementoMenu; for (var i:uint = 0; i < (modoXML.section.length() - 1); i++) { boton = new ElementoMenu(); boton.Texto_txt.text = modoXML.section[i]. @ name; boton.nomm = i; boton.addEventListener(MouseEvent.MOUSE_UP, selectxml); boton.x = 50; boton.y = 50 + (i * 25); boton.buttonMode = true; boton.mouseChildren = false; addChild(boton); } } //Crear menu 2 ----------------------------------------------------------------- var ultimoXML:Number = 0; var xmlselect:String = ""; function selectxml(e:MouseEvent) { //borrar menus2 anteriores for (var i:uint = (ultimoXML + 1); i > 1; i--) { stage.removeChildAt(i-1); } //cargar segundo xml var xmlselect:String = "xmls/" + e.currentTarget.nomm + ".xml"; tes.text = xmlselect;//*-*-*-*-*-*-* var datos:XML; var XMLlamado2:URLRequest = new URLRequest(xmlselect); var XMLCargador2:URLLoader = new URLLoader(XMLlamado2); XMLCargador2.addEventListener(Event.COMPLETE, XMLCargado2); function XMLCargado2(e2:Event):void { datos = new XML(e2.target.data); ultimoXML = datos.item.length(); montarmenu2(); } //crear nuevos menus2 function montarmenu2():void { var boton2:ElementoMenu; for (var i:uint = 0; i < datos.item.length(); i++) { boton2 = new ElementoMenu(); boton2.Texto_txt.text = datos.item[i]. @ name; boton2.nombre = xmlselect boton2.contenido = datos; boton2.addEventListener(MouseEvent.MOUSE_UP, formulario); boton2.x = 220; boton2.y = 50 + (i * 25); boton2.buttonMode = true; boton2.mouseChildren = false; stage.addChild(boton2); } } } // Activacion del Formulario -------------------------------------------------------- function formulario(e2:MouseEvent) { var nombre:String = e2.currentTarget.nombre; var datos:XML = XML(e2.currentTarget.contenido); // Ejecutar funcion uploadfile con tecla enter ---------------------------------- txtdesc.addEventListener(KeyboardEvent.KEY_UP, onkeydown); function onkeydown(event:KeyboardEvent):void { switch (event.keyCode) { case Keyboard.ENTER : uploadfile(); } } // Ejecutar funcion uploadfile con mouse ----------------------------------------- btnupload.addEventListener(MouseEvent.MOUSE_UP, onmousedown); function onmousedown(event:MouseEvent):void { uploadfile(); } // Funcion para subir el archivo y escribir el xml -------------------------------- function uploadfile():void { if (txtname.text != "" && txtdesc.text != "") { var valname:String = txtname.text; var valdesc:String = txtdesc.text; var newwork:XML = <item></item>; newwork. @ name = valname; newwork. @ desc = valdesc; datos.prependChild(newwork); /// Enviar datos al archivo php --------------------------------------- var enviar:URLRequest = new URLRequest("savexml1.php"); var recibir:URLLoader = new URLLoader(); var variables:URLVariables = new URLVariables(); variables.nombre = nombre; variables.archivo = datos; enviar.method = URLRequestMethod.POST; enviar.data = variables; recibir.dataFormat = URLLoaderDataFormat.VARIABLES; recibir.addEventListener(Event.COMPLETE,Respuesta); recibir.addEventListener(IOErrorEvent.IO_ERROR,HayError); recibir.load(enviar); tes.text = "Subiendo archivos..."; } else { tes.text = "llena todos los campos"; } } } //Funcion que se ejecuta al recibir una respuesta del PHP, recibiendo la variable resultado. function Respuesta(event:Event) { tes.text = event.target.data.resultado; } //Función que se ejectuta cuando no se puede cargar el PHP function HayError(event:IOErrorEvent):void { tes.text = "Error al subir archivos"; } stop();
disculpen si esta un poco largo, lo puse asi para si le era util a alguien , esta comentado todo y la parte esencial es donde comento
// Funcion para subir el archivo y escribir el xml --------------------
Y aca el php, muy basico que es donde me imagino deba estar el lio
Código PHP :
<?php $nombre = $_POST['nombre']; $xml = $_POST['archivo']; echo "resultado= $xml"; $file = fopen($nombre,"wb"); fwrite($file, $archivo); fclose($file); ?>
Aca pongo ademas el xml inicial
Código XML :
<gallery> <item url='galeria/3_impreso/Grandes/1.jpg' thumb='galeria/3_impreso/Pequeñas/1.jpg' name = 'Foto de prueba' desc = 'Descripcion de prueba de esta imagen en modowebsite' ></item> </gallery>
y el que me genrael php
Código XML :
<gallery> <item name=\"prueba\" desc=\"prueba\"/> <item url=\"galeria/3_impreso/Grandes/1.jpg\" thumb=\"galeria/3_impreso/Pequeñas/1.jpg\" name=\"Foto de prueba\" desc=\"Descripcion de prueba de esta imagen en modowebsite\"/> </gallery>
Como ven aparece el dichoso backslash delante de todas las comillas y no se puede utilizar ese xml mas nunca en la vida.
Agradezco cualquier ayuda y podria enviarle los archivos al que desee si asi los puede revisar mejor pq la verdad ahora mismo no tengo idea de como subirlos aqui.