Skip to content

Instantly share code, notes, and snippets.

@quique123
Created December 8, 2009 23:52
Show Gist options
  • Save quique123/252112 to your computer and use it in GitHub Desktop.
Save quique123/252112 to your computer and use it in GitHub Desktop.
<?php
if(isset($_POST['create_xml'])){
echo "Links Data Posted";
/* All Links data from the form is now being stored in variables in string format */
$urlDoc = $_POST['urlDoc'];
$urlAdd = $_POST['urlAdd'];
$urlDes = $_POST['urlDes'];
$xmlBeg = "<?xml version='1.0' encoding='ISO-8859-1'?>";
$rootELementStart = "<$urlDoc>";
$rootElementEnd = "</$urlDoc>";
$xml_document= $xmlBeg;
$xml_document .= $rootELementStart;
$xml_document .= "<site>";
$xml_document .= $urlAdd;
$xml_document .= "</site>";
$xml_document .= "<description>";
$xml_document .= $urlDes;
$xml_document .= "</description>";
$xml_document .= $rootElementEnd;
$path_dir = "/";
$path_dir .= $urlDoc .".xml";
echo "<br>" .$urlAdd. "<br>";
echo $xml_document. "<br>";
echo $path_dir. "<br>";
/* Data in Variables ready to be written to an XML file */
$fp = fopen($path_dir,'w+');
$write = fwrite($fp,$xml_document);
/* Loading the created XML file to check contents */
$sites = simplexml_load_file("$path_dir");
echo "<br> Checking the loaded file <br>" .$path_dir. "<br>";
echo "<br><br>Whats inside loaded XML file?<br>";
print_r($sites);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment