Skip to content

Instantly share code, notes, and snippets.

@colin-haber
Created November 1, 2011 20:55
Show Gist options
  • Select an option

  • Save colin-haber/1331874 to your computer and use it in GitHub Desktop.

Select an option

Save colin-haber/1331874 to your computer and use it in GitHub Desktop.
Using minidom to get values from XML. Is this really the easiest way to do it?
<plugin>
<name>Plugin</name>
<version>0.0.0</version>
<description>The framework upon which all Dojo plugins are built.</description>
<url>http://n1nja.com/projects/dojo-server/core/</url>
<authors>
<author>
<name>Colin Haber</name>
<nickname>N1nja</nickname>
<mcname>anorexicpuppy</mcname>
<url>http://n1nja.com/</url>
</author>
</authors>
</plugin>
def getTitle(self, filename="manifest.xml"):
doc = minidom.parse(filename)
plugin = doc.childNodes[0]
for node in plugin.childNodes:
if node.nodeType == Node.ELEMENT_NODE and node.nodeName == "name":
for child in node.childNodes:
if child.nodeType == Node.TEXT_NODE:
return child.data
@flps42
Copy link
Copy Markdown

flps42 commented Nov 1, 2011

This is true. Then what you have is best as far as I know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment