lxml to parse html
contro opinion
contropinion at gmail.com
Mon Jan 23 02:34:09 EST 2012
import lxml.html
myxml='''
<cooperate>
<job DecreaseHour="1" table="tpa_radio_sum">
</job>
<job DecreaseHour="2"
table="tpa_radio_sum">
</job>
<job DecreaseHour="3" table="tpa_radio_sum">
</job>
</cooperate>
'''
root=lxml.html.fromstring(myxml)
nodes1=root.xpath('//job[@DecreaseHour="1"]')
nodes2=root.xpath('//job[@ne_type="101"]')
print "nodes1=",nodes1
print "nodes2=",nodes2
what i get is:
nodes1=[] and
nodes2=[<Element job at 0x13636f0>]
why nodes1 is []?nodes2=[<Element job at 0x13636f0>],
it is so strange thing?why ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120123/758c9303/attachment.html>
More information about the Python-list
mailing list