← Questions
Parse HTML into an element tree and query it
0
I was asked this
No reports yet. Sign in to say where you were asked 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 official answer yet. Write yours on the right and run it.
Nothing published yet.
Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding
