Code:
data = """<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg width="512" height="512" viewBox="0 0 135.46666 135.46667" version="1.1" id="svg1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <g id="layer1"> <rect style="fill:none;stroke:#000000;stroke-width:7.63634;" id="rect1" width="127.83032" height="127.83032" x="3.8181739" y="3.8181739" rx="12.48343" ry="12.483429" /> <text xml:space="preserve" style="font-size:160px;font-family:Roboto;text-align:center;text-anchor:middle;fill:#000000" x="67.694031" y="124.96131" id="text1"> <tspan id="tspan1" x="69.87413" y="124.96131">A</tspan></text> <tspan id="tspan1" x="69.87413" y="124.96131">B</tspan> </g> <tspan id="tspan2" x="69.87413" y="124.96131">C</tspan></svg>"""import xml.etree.ElementTree as ETroot=ET.fromstring(data)ns = {'default': 'http://www.w3.org/2000/svg', 'svg': 'http://www.w3.org/2000/svg'}# use iterfind with an xpath to find all occurences of tspanfor tspan in root.iterfind(".//default:tspan", ns): print(tspan.text)Statistics: Posted by ghp — Sun Feb 01, 2026 10:15 pm