Python parsing html mismatched tag error
<pre><code>30   &lt;li class="start_1"&gt;
31               &lt;input type="checkbox" name="word_ids[]" value="34" class="list_check"&gt;
32          &lt;/li&gt; 
</code></pre>

<p>This is a part of html file that I want to parse. But when I applied </p>

<pre><code>uh = open('1.htm','r')
data = uh.read()
print data  
tree = ET.fromstring(data)
</code></pre>

<p>It showed</p>

<blockquote>
  <p>xml.etree.ElementTree.ParseError: mismatched tag: line 32, column 18</p>
</blockquote>

<p>I don't know what is going wrong?</p>

<p>To parse HTML in Python i use lxml:</p>

<pre><code>import lxml.html
// html string
dom = '&lt;li class="start_1"&gt;...&lt;/li&gt;'
// get the root node
root_node = lxml.html.fromstring(dom)
</code></pre>

<p>after that you can play with it, for example using xpath:</p>

<pre><code>nodes = root_node.xpath("//*")
</code></pre>

python html parsing