XML to Tree
Given a valid XML document, convert an XML string to an n-ary tree.
We'll cover the following...
Statement
Given a valid XML document, construct a tree structure that correctly represents the hierarchical relations between the nodes in the XML document.
As support, an XML Node class is defined in the lesson. Each node stores the name of the node and, the list of its child nodes. We will not store XML attributes, only the name of the node.
Additionally, an XML Tokenizer class is also provided. This class implements the Get Next Element function that can be called in a loop to return all the XML tokens in the string, classified as one of:
- Element opening tag
- Element closing tag
- Element text
- Unknown element (a catch-all for unrecognized tokens)
Access this course and 1400+ top-rated courses and projects.