This is test task, i made by custom reqruimenents.
- Script should parse folders and sub-folders to look for XML files.
- Show folders structure and files with WEB UI for user.
- Parse/get content of all XML files and option to insert them to database.
- Review all current database data.
- Search animal with parameter "name". Search should be valid for atleast 3 languages: Bulgarian, Korean, Japaneese.
In folder "animals" i created XML files with data objects, reffered to animals. Object structure:
<animal>
<category></category>
<name></name>
<description></description>
<eat></eat>
</animal>
I build custom PHP API, using Bootstrap 3.0, jQuery, Ajax and PHP-PDO for secure database connection. Escape dangerous tags and possible XSS attack.
I have four tabs on homepage, showing:
- Show Database – show all current rows from database
- Show XML file paths – show full paths to all XML files inside scanned directory in multiple level deep. - Button to import XML data into database - If XML element exist in database, script will update current row’s data and update value for date_created timestamp.
- Show XML file contents – show all structured data from XML files.
- Show directory tree – show all files and subfolders inside $dir_path. - Created test files (test.txt) to ensure script escapes not XML files.
-
On the top of the page you can search for animals in database by animal’s name.
-
Filtered XSS validation.
- Download project ZIP file or clone it via GIT with command:
HTTPS
git clone https://github.com/krasimirkostadinov/XML-Parser.git
SSH
git clone git@github.com:krasimirkostadinov/XML-Parser.git
- Create MySQL database at your setup.
- Import "animals.sql" file from projec root folder. This is initial database with just a few records.
- Configure virtualhost and set execute permission to project root folder (if Linux based).
- Please setup your project settings in ./config.php file. !important config settings: - HOST_PATH - host path (also URL) to your local project. It is used also for loading resource files. - DB_USER - user for database connection - DB_PASS - user's password for database connection - $dir_path - folder to parse (default /animals)



