I have a xml file like below:
<alarms rootMIB="1" source="PLATFORM">
<alarm alarmCode="123" alarmMIBName="chassde">
<alarmObject>CHASSIS</alarmObject>
<alarmType>equipmentAlarm</alarmType>
<probableCause>equipmentMalfunction</probableCause>
<description>Report</description>
</alarm>
</alarms>
And I can get the attribute of “alarmCode” and “alarmMIBName” by below code:
import xml.dom.minidom
for alarm_tag in dom.getElementsByTagName('alarm'):
if alarm_tag.hasAttribute('alarmMIBName'):
alarmmibname = str(alarm_tag.getAttribute('alarmMIBName'))
But I also want to print the whole line that hasAttribute ‘alarmMIBName’, that is the line:
<alarm alarmCode="123" alarmMIBName="chassde">
Could anyone tell me how to print the whole line?
Thanks a lot!
This works for me