
September 8th, 2008, 02:39 AM
|
|
Registered User
|
|
Join Date: Sep 2008
Posts: 3
Time spent in forums: 1 h 9 m 10 sec
Reputation Power: 0
|
|
|
Here you can go.
$_POST['image'], $_POST['caption'], $_POST['url'] are the posted HTML elements names.
$image = $_POST['image'];
$caption = $_POST['caption'];
$image = $_POST['url'];
After gathering all data from the form then, I created a variable to hold all the data entered by user in string format.
$xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
$rootELementStart = "<employee>";
$rootElementEnd = "</employee>";
$xml_doc= $xml_dec;
$xml_doc .= $rootELementStart;
$xml_doc .= "<image>";
$xml_doc .= $image;
$xml_doc .= "</image>";
$xml_doc .= "<caption>";
$xml_doc .= $caption;
$xml_doc .= "</caption>";
$xml_doc .= "<url>";
$xml_doc .= $url;
$xml_doc .= "</url>";
$xml_doc .= $rootElementEnd;
$fp = fopen("example.xml",'w');
$write = fwrite($fp,$xml_doc);
fopen function opens file or URL. I assume that xml_file directory is there so I have checked for error during fopen function call.
I have used fwrite($fp,$xml_doc); to store the xml string into a file.
_________________________
RichAppsConsulting
|