Python: Find Unique XML Attributes
<p>I have a XML file with a structure similar to this</p>

<pre><code>&lt;records&gt;
    &lt;record something="this" name="ABC"/&gt;
    &lt;record something="this" name="DEF"/&gt;
    &lt;record name="ABC"  something="this"/&gt;
    &lt;record name="GHI"  something="this"/&gt;
    &lt;record something="this" name="ABC/&gt;
</code></pre>

<p>What I am looking for is a Python script to bring back all unique attribute values with the attribute name of <code>name</code> i.e.</p>

<pre><code>ABC
DEF
GHI
</code></pre>

<p>The script runs fine when I put the filename in myself but when it is passed through as a parameter, it falls over.</p>

<pre><code>from xml.dom import minidom
import sys
print sys.argv[1]
xmldoc = minidom.parse('/root/%s.xml' % sys.argv[1])
itemlist = list(xmldoc.getElementsByTagName('record'))
itemlist.sort()
for s in itemlist :
    if s.hasAttribute("name"):
        print s.attributes['name'].value
</code></pre>

<p>However it is still not bring back unique values</p>