load xml into php script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
barry_normal
Forum Newbie
Posts: 21
Joined: Sun Jul 02, 2006 5:02 am

load xml into php script

Post 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.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

You'll need to transmit the XML in text form, either in a file, or in a string at runtime.
barry_normal
Forum Newbie
Posts: 21
Joined: Sun Jul 02, 2006 5:02 am

Post 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
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post 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.
barry_normal
Forum Newbie
Posts: 21
Joined: Sun Jul 02, 2006 5:02 am

Post by barry_normal »

Hi Jenk,

That's the only logical way to do it.

Thanks for your help

Cheers
B
Post Reply