Page 1 of 1
Use Form Data to Create XML File?
Posted: Wed Jul 11, 2007 4:08 pm
by Sepai
I am brand new to PHP but would like to create a form in an HTML page that will use the data entered into it to display an XML file.
I fould this tutorial:
http://www.topxml.com/php_simplexml/default.asp
but didnt really understand it and was getting error messages when trying to use it:
Parse error: syntax error, unexpected T_STRING in /xml/php/employee.php on line 8
Code: Select all
$xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
Does anyone know of another tutorial is have any pointers to get me started?
Thanks.
Posted: Wed Jul 11, 2007 4:10 pm
by feyd
Can you posted the lines before that line too?
Posted: Wed Jul 11, 2007 4:12 pm
by Sepai
Yep sure:
Code: Select all
if(isset($_POST['create_employee'])){
echo "Employee Data Posted";
$xmlfileName = $_POST['xmlfileName'];
$empName = $_POST['empName'];
$empAddress = $_POST['empAddress'];
$empSSN = $_POST['empSSN'];
$empCompany = $_POST['empCompany'];
$xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
$rootELementStart = "<employee>";
$rootElementEnd = "</employee>";
$xml_doc= $xml_dec;
$xml_doc .= $rootELementStart;
$xml_doc .= "<employeename>";
$xml_doc .= $empName;
$xml_doc .= "</employeename>";
$xml_doc .= "<employeeaddress>";
$xml_doc .= $empAddress;
$xml_doc .= "</employeeaddress>";
$xml_doc .= "<SSN>";
$xml_doc .= $empSSN;
$xml_doc .= "</SSN>";
$xml_doc .= "<company>";
$xml_doc .= $empCompany;
$xml_doc .= "</company>";
$xml_doc .= $rootElementEnd;
$default_dir = "xml_files/";
$default_dir .= $xmlfileName .".xml";
$fp = fopen($default_dir,'w');
$write = fwrite($fp,$xml_doc);
Thats the whole php file.
Posted: Wed Jul 11, 2007 4:21 pm
by feyd
Outside of a missing closing brace for the if, I don't see any syntax errors.
Posted: Wed Jul 11, 2007 4:25 pm
by Sepai
Could it be something else?
This is what I want to create:
http://www.edutech.ch/vista/imsimport.php
Go down to
User Section Enrollment
Someting similiar to that.