Alright so I'm trying to get information from Yahoo finance using their YQL. The below code is what I'm using for that. I have tested the xml location string in a browser which does return xml code. I'm trying to read that code, parse it and MessageBox the node I'm looking for. The error is that the string text is null, I'm presuming this is because node is null, which is probably because doc is null. Why is doc null?
XmlDocument doc = new XmlDocument();
doc.Load("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.stocks%20where%20symbol%3D%22" + txt_Symbol.Text + "%22&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys");
XmlNode node = doc.DocumentElement.SelectSingleNode("/results/stock/FullTimeEmployees");
string text = node.InnerText;
Sample Response From Yahoo YQL:
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1" yahoo:created="2014-06-03T21:06:06Z" yahoo:lang="en-US">
<diagnostics>
<url execution-start-time="0" execution-stop-time="1" execution-time="1">
<![CDATA[
http://www.datatables.org/yahoo/finance/yahoo.finance.stocks.xml
]]>
</url>
<publiclyCallable>true</publiclyCallable>
<cache execution-start-time="4" execution-stop-time="4" execution-time="0" method="GET" type="MEMCACHED">
<![CDATA[ bcd022d1d39e092a7a1390d6f5cf574a ]]>
</cache>
<cache execution-start-time="4" execution-stop-time="5" execution-time="1" method="GET" type="MEMCACHED">
<![CDATA[ 32c5f8788e8bc68ba5e635ae25257e23 ]]>
</cache>
<cache execution-start-time="5" execution-stop-time="6" execution-time="1" method="GET" type="MEMCACHED">
<![CDATA[ 8c548d6a60dd1f067626b9ecdf556eb3 ]]>
</cache>
<url execution-start-time="5" execution-stop-time="288" execution-time="283">
<![CDATA[ http://finance.yahoo.com/q?s=ibm ]]>
</url>
<url execution-start-time="5" execution-stop-time="288" execution-time="283">
<![CDATA[ http://finance.yahoo.com/q?s=ibm ]]>
</url>
<query execution-start-time="5" execution-stop-time="294" execution-time="289" params="{url=[http://finance.yahoo.com/q?s=ibm]}">
<![CDATA[
select * from html where url=@url and xpath='//div[@id="yfi_investing_head"]/h1 | //div[@class="yfi_quote_summary"]/div[1]'
]]>
</query>
<url execution-start-time="5" execution-stop-time="430" execution-time="425">
<![CDATA[ http://finance.yahoo.com/q/pr?s=ibm ]]>
</url>
<url execution-start-time="5" execution-stop-time="430" execution-time="425">
<![CDATA[ http://finance.yahoo.com/q/pr?s=ibm ]]>
</url>
<url execution-start-time="7" execution-stop-time="455" execution-time="448">
<![CDATA[ http://finance.yahoo.com/q/hp?s=ibm ]]>
</url>
<query execution-start-time="4" execution-stop-time="434" execution-time="430" params="{url=[http://finance.yahoo.com/q/pr?s=ibm]}">
<![CDATA[
select * from html where url=@url and xpath='//table[@class="yfnc_datamodoutline1"]/tr/td/table/tr' limit 4
]]>
</query>
<url execution-start-time="7" execution-stop-time="455" execution-time="448">
<![CDATA[ http://finance.yahoo.com/q/hp?s=ibm ]]>
</url>
<query execution-start-time="6" execution-stop-time="461" execution-time="455" params="{url=[http://finance.yahoo.com/q/hp?s=ibm]}">
<![CDATA[
select * from html where url=@url and xpath='//option[@selected="selected"] | //input[@maxlength="2"] | //input[@maxlength="4"]'
]]>
</query>
<javascript execution-start-time="3" execution-stop-time="462" execution-time="459" instructions-used="46403" table-name="yahoo.finance.stocks"/>
<user-time>464</user-time>
<service-time>2251</service-time>
<build-version>0.2.2525</build-version>
</diagnostics>
<results>
<stock symbol="ibm">
<CompanyName/>
<start>1962-01-02</start>
<end>2014-06-03</end>
<Sector>Technology</Sector>
<Industry>Information Technology Services</Industry>
<FullTimeEmployees>431212</FullTimeEmployees>
</stock>
</results>
</query>
<!-- total: 464 -->
<!-- engine4.yql.bf1.yahoo.com -->