I realize XML is going to save us all from something or other, but I just can't get my head around it. <br>
<br>
I have been trying to do what should be a very simple action: Extract values from element tags.<br>
<br>
I first grab my data from a website with httplib:<br>
<br>
<br>
&gt;&gt; connection = httplib.HTTPSConnection(serverUrl)<br>
&gt;&gt; connection.request(&quot;POST&quot;, serverDir, buildRequestXml(&quot;ReturnAll&quot;, &quot;1&quot;), buildHttpHeaders())<br>
&gt;&gt; response = connection.getresponse()<br>
<br>
&gt;&gt; from xml.dom.minidom import parse, parseString<br>
<br>
&gt;&gt; data = response.read()<br>
&gt;&gt; connection.close()<br>
&gt;&gt; response = parseString(data)<br>
&gt;&gt; itemIDs = response.getElementsByTagName(&quot;ItemID&quot;)<br>
&gt;&gt; response.unlink()<br>
<br>
<br>
I have tried everything I can find to extract the values from the &lt;ItemID&gt; elements:<br>
<br>
&gt;&gt; for item in itemIDs:<br>
&gt;&gt;&nbsp; &nbsp;&nbsp; print item<br>
<br>
yeilds<br>
<br>
&lt;DOM Element: ItemID at 0x7f532c0c&gt;<br>
&lt;DOM Element: ItemID at 0x7f5400cc&gt;<br>
&lt;DOM Element: ItemID at 0x7f54656c&gt;<br>
&lt;DOM Element: ItemID at 0x7f54ea0c&gt;<br>
&lt;DOM Element: ItemID at 0x7f555eac&gt;<br>
<br>
Okay, no problem. Now all I have to do is figure out which
particlular.string.of.words.interconnected.by.periods to pass to
extract the values.<br>
<br>
&gt;&gt; for item in itemIDs:<br>
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; print item.nodeValue<br>
<br>
Seems logical:<br>
<br>
None<br>
None<br>
None<br>
None<br>
None<br>
<br>
Oh for crying out loud ...<br>
<br>
Hmmm ... I have saved the output from response.read() to a file and
sure enough, amid all the other element tags, I find the expected
values in &lt;ItemID&gt;<br>
<br>
My problem is: I'm ignorant. I don't know whether my data is being
returned from parseString() as text, or a list or a beautiful rainbow
made of skittles and pixie droppings.&nbsp; The Python/XML howto and
the bajillion other &quot;XML made clear to YOU!&quot; sites I have looked at
have left me more confused ...&nbsp; I'm just completely lost in the
(apparently arbitrary) nomeclature of lists, nodes, elements, trees,
habitrails and intestines. (Yes, I'm just complaining now, but dang it!
I'm frustrated!<br>
<br>
*ahem*<br>
<br>
Could someone kindly point out where I am going wrong and perhaps send
me to a very *practical* introduction to reading data from a dom?<br>
<br>
Thanks!<br>
<br>
<br>
<br>
<br>