Thank you so much Dave,<br><br>This is very helpful.&nbsp; Have a happy holiday.<br><br>Mike<br><br><div><span class="gmail_quote">On 12/24/05, <b class="gmail_sendername">Dave Kuhlman</b> &lt;<a href="mailto:dkuhlman@cutter.rexx.com">
dkuhlman@cutter.rexx.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Fri, Dec 23, 2005 at 03:53:33PM -0500, Michael Gilbert wrote:
<br>&gt; Hello again,<br>&gt;<br>&gt; I think I found a way to accomplish my goal with minidom.&nbsp;&nbsp;Is this the most<br>&gt; direct solution for my goal, or is there a simpler way?&nbsp;&nbsp;Thanks again.<br><br>minidom is a good choice because it is part of the standard Python
<br>library.&nbsp;&nbsp;If you, or your users, are willing to install extra<br>software, you may want to look at ElementTree and lxml:<br><br>- ElementTree: <a href="http://effbot.org/zone/element-index.htm">http://effbot.org/zone/element-index.htm
</a><br><br>- lxml: <a href="http://codespeak.net/lxml/">http://codespeak.net/lxml/</a><br><br>They are DOM-like, but some consider it a better DOM.<br><br>&gt;<br>&gt; import xml.dom.minidom<br>&gt;<br>&gt; document = '&lt;user first=&quot;jean&quot; last=&quot;valjean&quot; dob=&quot;17290101&quot; children=&quot;1&quot;
<br>&gt; hobby=&quot;stealing bread&quot; /&gt;'<br>&gt;<br>&gt; dom = xml.dom.minidom.parseString(document)<br>&gt;<br>&gt; t = dom.getElementsByTagName(&quot;user&quot;)[0]<br>&gt;<br>&gt; if t.hasAttributes():<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; for cnt in range(0, 
t.attributes.length):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if t.attributes.item(cnt).nodeName == &quot;hobby&quot;:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'hobby = ' + t.attributes.item(cnt).nodeValue<br><br>Yes.&nbsp;&nbsp;But, there may be a slightly more direct way.&nbsp;&nbsp;minidom
<br>attributes are a NamedNodeMap which is a sort of dictionary-like<br>object.&nbsp;&nbsp;So you can use indexing, for example, in your case,<br>something like:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;t.attributes['hobby']<br><br>and also:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;if t.attributes.has_key
('hobby'):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;val = t.attributes['hobby']<br><br>Use dir(t.attributes) to get a list of other methods.<br><br>Dave<br><br>[snip]<br><br>--<br>Dave Kuhlman<br><a href="http://www.rexx.com/~dkuhlman">http://www.rexx.com/~dkuhlman
</a><br>_______________________________________________<br>XML-SIG maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:XML-SIG@python.org">XML-SIG@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/xml-sig">http://mail.python.org/mailman/listinfo/xml-sig
</a><br></blockquote></div><br>