我在 Python 中遍历一个 XML 文件,如下所示:
for node in rootNode1.iter():
print node.tag
我的输出是:
Student
Int_Class_ID
Name
StudentID
EmailID
Address
Int_Class_ID
Street
City
PostalCode
Seminar
Int_Class_ID
SeminarNumber
Course
现在我只想保存上面Int_Class_ID
这样的名称:
Student
Address
Seminar
有人可以帮忙吗?
我的 XML 文件是这样的:
<?xml version='1.0' encoding='UTF-8'?>
<ModelDiff>
<Student>
<Int_Class_ID>1</Int_Class_ID>
<Name>A</Name>
<StudentID>1</StudentID>
<EmailID>br</EmailID>
<Address>
<Int_Class_ID>3</Int_Class_ID>
<Street>c</Street>
<City>P</City>
<PostalCode>d</PostalCode>
</Address>
<Seminar>
<Int_Class_ID>4</Int_Class_ID>
<SeminarNumber>e</SeminarNumber>
<Course type="f">
<Int_Class_ID>11</Int_Class_ID>
<TopicName>g</TopicName>
<Day>Monday</Day>
<Date>15/04/2013</Date>
</Course>
</Student>