Monday, 11 August 2014

Creating XML in PHP saves a blank file



im new to XML Handling in PHP i wrote this script to get variables from post and insert them into a tag with the name of the variable it self from the posted variables and the data the actual data inside this text fields i have set $id_picture to foo instead of the posted data but with same result



$xml = new DOMDocument('1.0', 'UTF-8');

$id_picture = $_POST['id_picture'];
$xml_id_picture = $xml->createElement("id_picture");
$xml_id_picture_node = $xml->createTextNode($id_picture);
$xml_id_picture->appendChild($xml_id_picture_node);
//upload xml
$xml->save('xml.xml');


what im trying to achieve is save the data from the post to the first variable then i get lost on making it a xml tag and inserting the data in between



<id_picture>foo</id_picture>

No comments:

Post a Comment