- Single-pass
- Non-recursive
- Simple character-scan of xml-string
- No use of find, indexOf ...
- XML-parsing
- Javascript:
deno test -A
- Python:
python ./src/python/xml_parser_test.py
Simply call the following static method (as in the demo-class):
XmlParser.parse(xmlString)
- Data Model
- XmlTag: Name, indices, attributes ... of an XML-tag
- XmlNode: Graph-based model for values, children ... of an XML-node
- Logic
- Detect tags
- Scan tags
- Generate new nodes with new start tags (<>)
- Keep track of the previous tag/node
- Associate a new node with its parent
- Assign values to leaves upon detection of an end tag (</>)
Extraction of tags and creation of nodes may be done in parallel or serially (the flag extractAllTagsFirst
).