-
xml_parser.py: The core logic to parse the XML files and build the tree structure
- Class
TreeNode
: Class to create a node of the XML tree - Class
ParseTree
: A class to parse the XML stringbuild_tree()
: Given an XML string, it builds a tree with the help of several helper functions such as _handle_tagprint_tree()
: Prints the tree structure (level order traversal)extract_tags()
: Traverses through the built tree and extractsxml_data
using Depth First Search
- Class
-
unit_tests.py
: A list of unit tests to verify the working ofxml_parser.py
-
app.py
: the flask server which invokesxml_parser.py
and delivers the result -
run_app.py
: Runs the flask server on port 3456, as per the requirements
Download this repository to a folder. You should have a folder XMLParser in your machine.
Install Python 3 and pip
Navigate to the folder XMLParser via terminal
Run python3 run_server.py
on UNIX-based systems OR
Run python run_server.py
on Windows
Errors are logged to the terminal. The errors and warnings are described in xml_parser.py
- For now the errors and warnings are logged. Robust exception handling mechanisms should be introduced
- For now, due to lack of time, I have focused on catching the errors but not on handling them
- Logging the data should enable insights and some sort of visualization
- Standardizing the error logs and connecting it to a database like Elasticache would enable better insights for the future
- Need to integerate it with some kind of a database so that the document is parsed only once and not on every request