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!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.
Hello:
I would like to store the <path> value from this XML, then use the variable to save this XML to a file. I'm passing the XML data from Flash to PHP.
<?php
$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
$sxe = simplexml_load_string($xml);
if ($sxe === false) {
echo 'Error while parsing the document';
exit;
}
$dom_sxe = dom_import_simplexml($sxe);
if (!$dom_sxe) {
echo 'Error while converting XML';
exit;
}
$dom = new DOMDocument('1.0');
$dom_sxe = $dom->importNode($dom_sxe, true);
$dom_sxe = $dom->appendChild($dom_sxe);
echo $dom->save('test.xml');
?>
The PHP code works as-is, but I cannot figure out how to extract that path value from the XML then use it in my echo save. Any ideas? I've experimented with different Googled solutions for about 3 hours on this. I'm stumped.
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.
Thanks dude81. I have tried 3 hours worth of solutions and have not been able to get that to work. Can you provide the specific code that I need to write?
Here is the end result of my code. This php script accepts raw xml data from Flash (AS3), converts to a DOM object, extracts a node value containing a save location, then saves to that location. Works.
Get rid of the ->store part. As the required top-level element it's obvious that you have to navigate through it, so $simplexmlelement->node is the "node" child of that top element.