Parse HTML into an element tree and query it
You are asked to "write an HTML parser" with no definition of the input, the output or the edge cases. Part of the exercise is pinning that down: ask for examples, then write down what the input looks like, what you return, and which cases you handle (nesting, self-closing tags, attributes, text, malformed markup). Then parse the markup into a tree of elements and answer queries over it with a depth-first search, such as finding every element with a given tag or attribute.
No answer yet. Write the first one; the best answer gets endorsed.
