I have a problem getting to the right solution. I want to delete <question> and its children if <answer> is = 99. As a result, I need a string with the filtered questions. I have the following html structure:
<html>
<body>
<questionaire>
<question>
<questiontext>
Do I have a question?
</questiontext>
<answer>
99
</answer>
</question>
<question>
<questiontext>
Do I love HTML/XML parsing?
</questiontext>
<questalter>
<choice>
1 oh god yeah
</choice>
<choice>
2 that makes me feel good
</choice>
<choice>
3 oh hmm noo
</choice>
<choice>
4 totally
</choice>
</questalter>
<answer>
4
</answer>
</question>
<question>
</questionaire>
</body>
</html>
So far i tried to realize it with xpath…but lxml.html has no iterparse…has it? Thanx!
This will do exactly what you need:
Result: