我正在使用 ElemetTree 来迭代所有的 xml 标签。而我的一些 xml 内容看起来像下面的 xml。当迭代 xml 时,
<result1>
标记文本为 None 而不是“这是 Chrome 浏览器的结果”
<?xml version="1.0" encoding="UTF-8"?>
<article>
<result1 id="val1"><h2>Google Chrome</h2>
This is the Result of Chrome Browser<p>Google Chrome is a web browser developed by Google, released in 2008. Chrome is the world's
most popular web browser today!</p></result1>
</article>
蟒蛇
import xml.etree.ElementTree as ET
treexml = ET.parse('exam.xml')
for elemintree in treexml.iter():
print(elemintree.tag,elemintree.text)
O/P 获取
article
result1 None
h2 Google Chrome
p Google Chrome is a web browser developed by Google, released in 2008. Chrome is the world's
most popular web browser today!
需要O / P
h2 Google Chrome
This is the Result of Chrome Browser
p Google Chrome is a web browser developed by Google, released in 2008. Chrome is the world's
most popular web browser today!
请帮助!!