First : am a new beg. using python..so please help me out.I'm trying to read a XML file using Python. My xml file name is rgpost.xml
<volume name="sp" type="span" operation="create">
<driver>HDD1</driver>
</volume>
My code :
import xml.etree.ElementTree as ET
doc = ET.parse("rgpost.xml")
s = doc.find("volume")
print s.attrib["name"]
While running this am getting error :
sp:~# python volume_check.py volume
Traceback (most recent call last):
File "volume_check.py", line 13, in <module>
print s.attrib["name"]
AttributeError: 'NoneType' object has no attribute 'attrib'
Thanks in advance