尝试解析data.xspf并遵循它Python 3.6.8并找到元素但有输出。LXML 4.4.1<creator>Creator</creator>[]数据.xspf<?xml version="1.0" encoding="UTF-8"?><playlist xmlns="http://xspf.org/ns/0/" version="1"> <title/> <creator/> <trackList> <track> <location>http://localhost:8000</location> <creator>Creator</creator> <title>Title</title> <annotation>BlahBlahBlahBlahBlahBlahBlah</annotation> <info>info</info> </track> </trackList></playlist>脚本:>>> from lxml import etree>>> tree = etree.parse("data.xspf")>>> tree.findall('.//creator')任何的想法?
1 回答
慕容森
TA贡献1853条经验 获得超18个赞
使用函数的第二个参数来确保默认命名空间被考虑在内tree.findall('.//creator', { None : 'http://xspf.org/ns/0/' })
。
添加回答
举报
0/150
提交
取消