This is a PHP page/script that reads data from an XML file and outputs the data to a CSV file.
Here's the details...
Web page with upload. When user clicks upload
- Validate inputs (xml extension)
If inputs invalid
- Print error to Web page.
If inputs valid
- Upload XML file to server.
- Validate XML file (it is valid if you can create the CSV from it).
If file invalid
- Print error to Web page.
If file valid
- Create a CSV file.
- Print statistics to Web page (number of records, number of fields).
- Download the CSV file to client.
XML FILE SPECS
Each XML file will have a single <records> tag.
Each <records> tag will have one or more <record> tags within it.
Each <record> tag will have a single <recordname> tag within it.
Each <record> tag will have a single <fields> tag within it.
Each <fields> tag will have one or more <field> tags within it.
Each record will have the same number of <field> tags.
Each <field> tag will have a single <fieldname> tag within it.
Each <field> tag will have a single <fielddata> tag within it.
If any of these specs is false, the XML file is invalid.
Each XML file may have a different set of fields (you can't hard code the fields).