Hello, i am wondering how to properly format xml that is generated from PHP. Here is my example.
I need it to look like this:
<event title="Trade Show" place="West Palm Beach, Florida" description="This trade show will display all new jewelery from arond the globe" startDate="2006-12-14 17:30:00" endDate="2006-12-14 19:30:00" allDay="0" eventType="once" />
Here is how it is generating:
<event title= Main Event place= Cherry Hill, NJ description= Jewlry Show startDate= 2006-12-15 17:30:00 endDate= 2006-12-15 19:30:00 allDay=0 eventType=once/>
basically there are no “” around the data which is required! Any suggestions? Here is my source code:
<?
if(isset($_POST['create_employee'])){
echo "Calendar Event Successfully Added";
$title = $_POST['title'];
$place = $_POST['place'];
$description = $_POST['description'];
$start = $_POST['start'];
$end = $_POST['end'];
$allday = $_POST['allday'];
$onetime = $_POST['onetime'];
$recurring = $_POST['recurring'];
//After gathering all data from the form then, I created a variable to hold all the data entered by user in string format.
$xml_doc= $xml_dec;
$xml_doc .= $rootELementStart;
$xml_doc .= "<event title= ";
$xml_doc .= $title;
$xml_doc .= " place= ";
$xml_doc .= $place;
$xml_doc .= " description= ";
$xml_doc .= $description;
$xml_doc .= " startDate= ";
$xml_doc .= $start;
$xml_doc .= " endDate= ";
$xml_doc .= $end;
$xml_doc .= " allDay=";
$xml_doc .= "0";
$xml_doc .= " eventType=";
$xml_doc .= "once";
$xml_doc .= "/>";
$file .= "employee.xml";
//Here I have taken default directory as xml_file directory.
//After creating string representation of employee data, I have used following PHP script to store in the file
$fp = fopen($file,'a+');
$write = fwrite($fp,$xml_doc);
}
?>
Thank you!!