Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I tried to reproduce your error, but it printed just fine for me.</p> <p>I tried loading your data from a string within the Python module, I tried loading your data from a named file, and I tried loading your data from a file object. They all handled the colon just fine.</p> <p>The only difference now seems to be the way you get the data: urllib2.openurl(). Perhaps the data returned by that function is not exactly what minidom expects. Or perhaps it does something with the colon character.</p> <p>Here is the code I used (The test.xml file contains the same xml data as in the triple-quoted string):</p> <pre><code>from xml.dom import minidom src = """ &lt;Schedule Season="2010" Timezone="Eastern"&gt; &lt;Game gameId="1" Week="1" GameDate="2010-09-09" AwayTeam="MIN" HomeTeam="NO" GameTime="8:30 PM"/&gt; &lt;Game gameId="2" Week="1" GameDate="2010-09-12" AwayTeam="MIA" HomeTeam="BUF" GameTime="1:00 PM"/&gt; &lt;Game gameId="3" Week="1" GameDate="2010-09-12" AwayTeam="DET" HomeTeam="CHI" GameTime="1:00 PM"/&gt; &lt;Game gameId="4" Week="1" GameDate="2010-09-12" AwayTeam="OAK" HomeTeam="TEN" GameTime="1:00 PM"/&gt; &lt;/Schedule&gt; """ def test_print(dom): for node in dom.getElementsByTagName('Game'): print node.getAttribute('AwayTeam'), print node.getAttribute('HomeTeam'), print node.getAttribute('Week'), print node.getAttribute('gameId'), print node.getAttribute('GameDate'), print node.getAttribute('GameTime') print '' dom = minidom.parseString(src) test_print(dom) dom = minidom.parse('data.xml') test_print(dom) f = open('data.xml', 'r') dom = minidom.parse(f) test_print(dom) f.close() url = 'http://api.fantasyfootballnerd.com/ffnScheduleXML.php?apiKey=1' dom = minidom.parse(urllib2.urlopen(url)) test_print(dom) </code></pre> <p>Edits: Added test for URL provided by Mike (original post author).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload