Reading xml file and printing using python
<p>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</p>

<pre><code>&lt;volume name="sp" type="span" operation="create"&gt;
    &lt;driver&gt;HDD1&lt;/driver&gt;
&lt;/volume&gt;
</code></pre>

<p>My code :</p>

<pre><code>import xml.etree.ElementTree as ET
doc = ET.parse("rgpost.xml")
s = doc.find("volume")
print s.attrib["name"]
</code></pre>

<p>While running this am getting error :</p>

<pre><code>sp:~# python volume_check.py volume  
Traceback (most recent call last):  
  File "volume_check.py", line 13, in &lt;module&gt;  
    print s.attrib["name"]  
AttributeError: 'NoneType' object has no attribute 'attrib'
</code></pre>

<p>Thanks in advance</p>
