我正在从OpenSubtitles.org解析XML,XML的格式如下:
<?xml version="1.0" encoding="utf-8"?>
<document id="6988661">
<s id="1">
<time id="T1S" value="00:00:00,587" />
Hello, StackOverflow
<time id="T1E" value="00:00:02,020" />
</s>
<s id="2">
<time id="T2S" value="00:00:02,043" />
This is a test
<time id="T2E" value="00:00:05,297" />
</s>
...
如何从<time>
标签之间获取无标签内容?我正在尝试将节目的成绩单保存到字符串中。
我当前正在使用内置的xml.etree.ElementTree
进行解析。使用root[0].text
返回'\n '
(第一个<time>
标记之前的内容)。使用root[n]
显示包含<s>
的只有两个孩子,两个<time>
标签。