amara

Python xpath not working?

家住魔仙堡 提交于 2019-12-20 05:39:06
问题 Okay, this is starting to drive me a little bit nuts. I've tried several xml/xpath libraries for Python, and can't figure out a simple way to get a stinkin' "title" element. The latest attempt looks like this (using Amara): def view(req, url): req.content_type = 'text/plain' doc = amara.parse(urlopen(url)) for node in doc.xml_xpath('//title'): req.write(str(node)+'\n') But that prints out nothing. My XML looks like this: http://programanddesign.com/feed/atom/ If I try //* instead of //title

Python xpath not working?

天大地大妈咪最大 提交于 2019-12-20 05:39:02
问题 Okay, this is starting to drive me a little bit nuts. I've tried several xml/xpath libraries for Python, and can't figure out a simple way to get a stinkin' "title" element. The latest attempt looks like this (using Amara): def view(req, url): req.content_type = 'text/plain' doc = amara.parse(urlopen(url)) for node in doc.xml_xpath('//title'): req.write(str(node)+'\n') But that prints out nothing. My XML looks like this: http://programanddesign.com/feed/atom/ If I try //* instead of //title