<?xml version="1.0" encoding="UTF-8"?>
<studentData xmlns="http://www.myschool.com/schmea/studentData" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation="http://www.myschool.com/schmea/studentData Studentdata.xsd">
<stuRec>
<as>
<sourceSys>BBC</sourceSys>
<acctDt>2023-04-04</acctDt>
</as>
<stats>
<ss>
<prov>AB</prov>
<cono>1</cono>
</ss>
</stats>
</stuRec>
<stuRec>
<as>
<sourceSys>RCD</sourceSys>
<acctDt>2023-05-14</acctDt>
</as>
<stats>
<ss>
<prov>ON</prov>
<cono>2</cono>
</ss>
</stats>
</stuRec>
</studentData>
import xml.etree.ElementTree as ET
mytree=ET.parse("/Users/user/student.xml")
myroot=mytree.getroot()
tag=myroot.tag
print(tag)
#attr=myroot.attrib
#print(attr)
for p in myroot.findall('.//studentData'):
acctDt=p.find('acctDt').text
**My XML file (student.xml) looks like above xml file: **When I run the python code I can print root tag and attribute but I get nothing from the loop, however, I want to get acctDt and prov:
user@star ~ % python -u "/Users/user/student.py"
{http://www.myschool.com/schmea/studentData}studentData
{'{http://www.w3.org/2000/10/XMLSchema-instance}schemaLocation': 'http://www.myschool.com/schmea/studentData Studentdata.xsd'}
user@star ~ %