【发布时间】:2018-05-26 06:04:02
【问题描述】:
我有以下 XML:
<xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<nite:root nite:id="ES2002a.topic"
xmlns:nite="http://nite.sourceforge.net/">
<topic nite:id="ES2002a.topic.vkaraisk.1" other_description="introduction of participants and their roles">
<nite:pointer role="scenario_topic_type" href="default-topics.xml#id(top.4)"/>
<nite:child href="ES2002a.B.words.xml#id(ES2002a.B.words0)..id(ES2002a.B.words71)"/>
<nite:child href="ES2002a.D.words.xml#id(ES2002a.D.words0)..id(ES2002a.D.words3)"/>
<nite:child href="ES2002a.A.words.xml#id(ES2002a.A.words0)..id(ES2002a.A.words12)"/>
<nite:child href="ES2002a.B.words.xml#id(ES2002a.B.words72)..id(ES2002a.B.words73)"/>
<nite:child href="ES2002a.D.words.xml#id(ES2002a.D.words4)..id(ES2002a.D.words11)"/>
<nite:child href="ES2002a.C.words.xml#id(ES2002a.C.words0)..id(ES2002a.C.words7)"/>
<nite:child href="ES2002a.D.words.xml#id(ES2002a.D.words12)..id(ES2002a.D.words13)"/>
</topic>
当我运行以下命令时,
[tag.name for tag in soup.find_all()]
我得到输出:
['html',
'body',
'nite:root',
'topic',
'nite:pointer',
'nite:child',
'nite:child',
'topic']
但是,当我尝试对 night:root、night:pointer、night:child 使用 find all 功能时。它返回一个空列表:
soup.find_all("nite:pointer")
返回:
[]
【问题讨论】:
标签: python xml python-3.x parsing beautifulsoup