Additional XML support in Zend Amf
November 25th, 2008
Support has been added to Zend Amf to return php objects of type DOMDocument and SimpleXML and receive an XML object in Flex ready for E4X. Note that you can already send an XML object from the flash player that results in a SimpleXML object in PHP.
Here is an example of the PHP service.
a b ';
$this->doc = new DOMDocument();
$this->doc->preserveWhiteSpace = false;
$this->doc->loadXML($sXML);
}
public function getDom()
{
return $this->doc;
}
public function getSimpleXml()
{
$simpleXml = simplexml_import_dom($this->doc);
return $simpleXml;
}
}


hi wade,
cool news! i’ve tried your sample code but i just get an the following error:
faultCode:Client.Error.DeliveryInDoubt
faultString:’Channel disconnected’
faultDetail:’Channel disconnected before an acknowledgement was received’
i use the “latest” zend framework 1.7.1. “full” from 2008-12-01.
any sugestions?
best regards
jan viehweger
@Jan Viehweger You will normally see that error if there is a PHP exception before the call could even be processed. Can you check your PHP error logs to see what is failing. It is probably something major like the class XmlTest could not be found.
@Jan: I recommend using Charles (http://www.charlesproxy.com/) to see the full server side error message. Extremely helpful for debugging puposes.
I sort of understand sending XML from php, however, using your approach above I was getting this error:
PHP Warning: DOMDocument::loadXML() [domdocument.loadxml]: Start tag expected, ‘<’ not found in Entity, line: 1 in …path\to\file.xml
So, I had to use:
//php:
$s = simplexml_load_file(‘path/to/file.xml’);
return $s;
And using Charles, I can see that 3 objects are being sent, one for each tier of the XML structure (root, with 2 children).
BUT I can’t seem to assign the object returned from Zendamf to an actionscript XML object.
Can you show an example of how to receive an XML object in actionscript ready for E4X?
Thanks! sd
Yeah, I don’t know…
…using DOMDocument, I can see using Charles that the returned result is merely empty, and when using simplexml, Zendamf returns an object containing two nested objects, as I mentioned above, one for each tier in the xml file, however, each of these objects is empty, the xml data does not transfer.
There’s no problem loading the xml file using DOM or simplexml and parsing the xml in php, so I know there’s no errors on the php-side, and as well, there’s no errors being logged by php…so I’m not sure how to proceed here.
I was under the impression from your post above that when passing either a DOM object or simplexml object, that actionscript would be able to receive and deal with the object as xml…
Confused, but that’s normal…
sd