lxml to parse html

contro opinion contropinion at gmail.com
Mon Jan 23 02:39:02 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[@table="tpa_radio_sum"]')
print "nodes1=",nodes1
print "nodes2=",nodes2


>>>
nodes1= []
nodes2= [<Element job at 0x1241240>, <Element job at 0x1362690>, <Element
job at 0x13626c0>]

would you mind to tell me  why nodes1=[]??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120123/a335f294/attachment-0001.html>


More information about the Python-list mailing list