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

相關文章
相關標籤/搜索