Page 1 of 1

load xml into php script

Posted: Thu Jul 13, 2006 8:46 am
by barry_normal
Hello there, this is baffling me a bit.

What I want to do is send an XML object from Flash to a PHP proxy script which will then contact external resources with the data contained in the XML object.

so the actionscript looks something like this:

Code: Select all

var xmlVal:XML = new XML();
		//xmlVal.xmlDecl = "<?xml version=\"1.0\"?>";
		//xmlVal.docTypeDecl = "\"<!DOCTYPE library[<!ELEMENT book (#PCDATA)>]>";
		var xnNewElement:XMLNode = new XMLNode(1, "location");
		var xnNewTextNode:XMLNode = new XMLNode(3, "London");
		xmlVal.appendChild(xnNewElement);
		xnNewElement.appendChild(xnNewTextNode);
		//trace(xmlVal.toString());
		xmlVal.send(proxima.php);

What I want to know is - how does proxima.php load that data? Do I need to save the XML as a file then open that from the script or can it actually be passed into the php some how?

Any help would be really appreciated.

Posted: Thu Jul 13, 2006 8:51 am
by Jenk
You'll need to transmit the XML in text form, either in a file, or in a string at runtime.

Posted: Thu Jul 13, 2006 9:03 am
by barry_normal
Hi Jenk,

I think the actionscript

Code: Select all

xmlVal.send(proxima.php);
should be sending the object as a string. I just don't know how to accept that incoming string in the php file.

I could save it as a file then open that with proxima.php but that seems to defeat the point of having a send() method...

Doesn't it?

Cheers
B

Posted: Thu Jul 13, 2006 9:10 am
by Jenk
PHP doesn't/can't 'listen' like other applications can, so you'll need to reverse the order in which events happen, you'll need to have PHP call for the XML. From file would be easiest if you are doing this in Flash.

Posted: Thu Jul 13, 2006 9:15 am
by barry_normal
Hi Jenk,

That's the only logical way to do it.

Thanks for your help

Cheers
B