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

解决办法:spa

from lxml import etreecode

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

root = xml.getroot()blog

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

更多语言参考it

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

相关文章
相关标签/搜索