首页
社区
课程
招聘
未解决 [求助]python解析xml的问题
发表于: 2020-9-17 14:23 1219

未解决 [求助]python解析xml的问题

2020-9-17 14:23
1219

<trackList>
<track>
<title>01 - Little People.mp3</title>
<location>h1</location>
</track>
<track>
<title>02 - Empty Shell.mp3</title>
<location>h2</location>
</track>
<track>
<title>03 - And Always.mp3</title>
<location>h3</location>
</track>
<track>
<title>04 - Your Hand Letter.mp3</title>
<location>h4</location>
</track>
<track>
<title>05 - Fairway.mp3</title>
<location>h5</location>
</track>
<title>06 - America Ended Song.mp3</title>
<location>h6</location>
<title>01 - Line Up.mp3</title>
<location>h7</location>
<title>02 - Self-Timer.mp3</title>
<location>h8</location>
<title>03 - Save Oneself.mp3</title>
<location>h9</location>
<title>04 - I'm Good Cheat.mp3</title>
<location>h10</location>
<title>05 - Let the Matter Rest.mp3</title>
<location>h11</location>
<title>06 - Self-Timer (Feat. Xiao Fei).mp3</title>
<location>h12</location>
<title>07 - Line Up (Confirmation Edition).mp3</title>
<location>h13</location>
</trackList>


[招生]系统0day安全班,企业级设备固件漏洞挖掘,Linux平台漏洞挖掘!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 1540
活跃值: (2807)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
我的代码如下,但是我只能打印显示没有被track包含住的内容。
如果想显示被track包含的内容应该怎么做?

from xml.etree import ElementTree
doc = ElementTree.parse("xml.txt")
for e in doc.findall("title"):
       print(e.text)
for f in doc.findall("location"):
       print(f.text)
2020-9-17 14:28
0
游客
登录 | 注册 方可回帖
返回
//