I'm using ElemetTree to iterate all the xml tag. Whereas some of my xml contents look like below xml. When iterating the xml getting the <result1>
tag text as None not "This is the Result of Chrome Browser"
<?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>
Python
import xml.etree.ElementTree as ET
treexml = ET.parse('exam.xml')
for elemintree in treexml.iter():
print(elemintree.tag,elemintree.text)
O/P Getting
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 Wanted
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!
Please Help!!
` element. https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.tail
– mzjn Mar 23 '23 at 10:18