python解析XML的三种方式
https://www.cnblogs.com/xiaobingqianrui/p/8405813.html
主要用xml.etree.ElementTree模块(简称 ET)来解析xml文件,它提供了轻量级的Python式的API。读取VOC数据集大致流程如下:
import xml.etree.ElementTree as ET
tree = ET.parse(file_name)
root = tree.getroot()
# 从size节点中读取宽高
size=root.find('size')
width = float(size.find('width').text)
height = float(size.find('height').text)
print(width,height)
for obj in root.iter('object'):
xml_box = obj.find('bndbox')
xmin = (int(xml_box.find('xmin').text))
ymin = (int(xml_box.find('ymin').text))
xmax = (int(xml_box.find('xmax').text))
ymax = (int(xml_box.find('ymax').text))
captionList = obj.findall('class') # find只能查找一个,findall可以查找所有的,class名可以换为其他子节点名
Pascal voc 数据集xml格式解析
https://blog.csdn.net/weixin_41278720/article/details/84872064
python xml提取多重标签内容
https://blog.csdn.net/qq_36076233/article/details/78989300