0

Malformed XML when selection stock option data

When I run a query such as:
select * from yahoo.finance.options where symbol="GDX"
the XML output is malformed.  Sometimes there is a "<changeDir/>" without a corresponding <changeDir>
My guess is that the option price change is neither up nor down (UP or DOWN is what appears within the node).
I don't know if that's by design...but it can create havoc for programs trying to loop through the output.  If it's by
design...I'd suggest a change adding "EVEN" or "NONE" or something like that...

by
3 Replies
  • <span style="font-family:'Courier New';">&lt;changeDir/&gt;</span> is valid XML; it is an empty element, one which has no content. <br><br>Do note that <span style="font-family:'Courier New';">&lt;changeDir/&gt;</span> is <strong>not</strong> a closing tag <span style="font-family:'Courier New';">&lt;/changeDir&gt;</span>.<br><br><div class="quote "><div class="quotetop ">QUOTE<cite>(johncblacker @ 26 Oct 2011 7:54 PM)</cite><blockquote class="quotemain">When I run a query such as:<br>select * from yahoo.finance.options where symbol=&quot;GDX&quot;<br>the XML output is malformed.&nbsp; Sometimes there is a &quot; &quot; without a corresponding <br>My guess is that the option price change is neither up nor down (UP or DOWN is what appears within the node).<br>I don&#39;t know if that&#39;s by design...but it can create havoc for programs trying to loop through the output.&nbsp; If it&#39;s by<br>design...I&#39;d suggest a change adding &quot;EVEN&quot; or &quot;NONE&quot; or something like that...</blockquote></div></div>
    0
  • Hmmmmm....ok, but if I&#39;m iterating through the node &quot;option&quot; when I get to index value 4, python throws an error as that index value doesn&#39;t exist.&nbsp; I guess I <br>should use a &quot;try&quot; block, but if as you indicate, that&#39;s valid XML then why does python (DOM) consider it an error.&nbsp; But, also, it seems to recognize that there <br>is something &quot;valid&quot; at index value &quot;4&quot; because when I extract the next (5) value, I get the correct one...namely the &quot;bid value&quot;...<br>Thanks for your help.<br><br><div class="quote"><div class="quotetop">QUOTE<cite>(Salathe @ 27 Oct 2011 5:11 AM)</cite></div><blockquote class="quotemain"><span style="FONT-FAMILY:'Courier New';">&lt;changeDir/&gt;</span> is valid XML; it is an empty element, one which has no content. <br><br>Do note that <span style="FONT-FAMILY:'Courier New';">&lt;changeDir/&gt;</span> is <strong>not</strong> a closing tag <span style="FONT-FAMILY:'Courier New';">&lt;/changeDir&gt;</span>.<br><br><div class="quote "><div class="quotetop ">QUOTE<cite>(johncblacker @ 26 Oct 2011 7:54 PM)</cite><blockquote class="quotemain">When I run a query such as:<br>select * from yahoo.finance.options where symbol=&quot;GDX&quot;<br>the XML output is malformed.&nbsp; Sometimes there is a &quot; &quot; without a corresponding <br>My guess is that the option price change is neither up nor down (UP or DOWN is what appears within the node).<br>I don&#39;t know if that&#39;s by design...but it can create havoc for programs trying to loop through the output.&nbsp; If it&#39;s by<br>design...I&#39;d suggest a change adding &quot;EVEN&quot; or &quot;NONE&quot; or something like that...</blockquote></div></div></blockquote></div>
    0
  • I am not a Python developer, nor a mind reader (so I&#39;ve no idea how broken your code might be), and this forum is not the ideal place for debugging your scripts. Have you tried posting your problem, the code you&#39;re using, etc. on a Q&A site like stackoverflow.com?<br><br><div class="quote "><div class="quotetop ">QUOTE<cite>(johncblacker @ 27 Oct 2011 9:13 AM)</cite><blockquote class="quotemain">Hmmmmm....ok, but if I&#39;m iterating through the node &quot;option&quot; when I get to index value 4, python throws an error as that index value doesn&#39;t exist.&nbsp; I guess I <br>should use a &quot;try&quot; block, but if as you indicate, that&#39;s valid XML then why does python (DOM) consider it an error.&nbsp; But, also, it seems to recognize that there <br>is something &quot;valid&quot; at index value &quot;4&quot; because when I extract the next (5) value, I get the correct one...namely the &quot;bid value&quot;...<br>Thanks for your help.</blockquote></div></div>
    0

Recent Posts

in YQL