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}")
技術的な知見や日々の記録、日常の些細な変化などを綴る雑記ブログです。専門的な技術解説から日記のようなライトな話題まで、特定のジャンルに縛られず、気になったことや面白いと感じた出来事を幅広く発信しています。筆者の視点で切り取った多様なコンテンツが楽しめる、自由な雑記空間を目指しています。
Sample of reading XML file with python
Sample of reading XML file with python
登録:
コメント (Atom)