python 使用xpath解析含有命名空间(xmlns)的xml

解决办法:

from lxml import etree

xml = etree.parse("./cee.xml")

root = xml.getroot()

print(root.xpath(".//i:Reviews", namespaces={"i":"http://www.bazaarvoice.com/xs/PRR/StandardClientFeed/14.7"}))

更多语言参考

https://stackoverflow.com/questions/40796231/how-does-xpath-deal-with-xml-namespaces

posted @ 2019-07-23 16:05  不止于python  阅读(1275)  评论(0编辑  收藏  举报