How can I make sure XML is well formed? Tags are properly nested and the XML is orderly.
Caveat: No helper functions, implement the function that validate the XML is correct.
Example:
<person>> //extra closing tags
<sex>>female</se>x>
<firstname>Amy</firstname>
<lastnam>e>Smith</lastnam>e>
</person>>
I tried implementing stack to solve this problem after researching some solutions but that implementation would fail if there are the same number of right and left tags - as the example above.
Although there are equal number of left and right tags when they're being retrieved from the stack the XML is incorrect, meaning the tags are in the wrong place.