Sample of reading XML file with python

Sample of reading XML file with python
import xml.etree.ElementTree as ET

# Load the XML file
tree = ET.parse('data.xml')
root = tree.getroot()

# Iterate through 'person' elements and extract data
for person in root.findall('person'):
    name = person.find('name').text
    age = person.find('age').text
    print(f"Name: {name}, Age: {age}")


コメント

このブログの人気の投稿

【iOS】SwiftでCGAffineTransformから角度・ラジアン・度数・スケールを計算する方法

【iOS】UILabelでヒラギノフォントの上下が切れる問題と対処法

【Android】WebViewのズームボタン(ピンチイン・ピンチアウト)を非表示にする方法