public void checkOnline()
{
try
{
XmlTextReader reader = new XmlTextReader("http://api.own3d.tv/liveCheck.php?live_id=" + id);
bool done = false;
while (reader.Read() && !done)
{
switch (reader.NodeType)
{
case XmlNodeType.Text:
if (streamOnline != bool.Parse(reader.Value) && !overridden)
{
streamOnline = bool.Parse(reader.Value);
if (streamOnline)
{
onlineStreams++;
}
else
{
onlineStreams--;
}
Announce();
}
break;
case XmlNodeType.EndElement:
done = true;
Console.WriteLine(nick + " online = " + streamOnline); // prints streamnamehere online = true/false
break;
}
}
}
catch (XmlException)
{
Console.WriteLine("File not found.");
}
}
例如读取的XML是:
{C}
它读取看看isLive是真实的
不过,我需要读取XML
例如读取的XML,它是:
<streams>
<stream>
<broadcast_part>1</broadcast_part>
<featured>True</featured>
<channel_subscription>True</channel_subscription>
<audio_codec>mp3</audio_codec>
<embed_count>73</embed_count>
<id href="/stream/show/2283462752.xml">2283462752</id>
<category>gaming</category>
<title>Showcraft - Monday/Wednesday 19:00 GMT - Vote Totalbiscuit King of the Web for charity! - http://tinyurl.com/votetotalbiscuit</title>
<video_height>720</video_height>
<site_count>669</site_count>
<embed_enabled>True</embed_enabled>
<up_time>Wed Dec 21 11:00:28 2011</up_time>
<meta_game>StarCraft II: Wings of Liberty</meta_game>
<format>live</format>
<stream_type>live</stream_type>
<channel_count>1490</channel_count>
<abuse_reported>False</abuse_reported>
<video_width>1280</video_width>
<geo>SE</geo>
<name href="/stream/show/live_user_totalbiscuit.xml">live_user_totalbiscuit</name>
<language>en</language>
<stream_count>742</stream_count>
<video_bitrate>1581.1953125</video_bitrate>
<channel>
<subcategory nil="true"/>
<category>gaming</category>
<id>12616386</id>
<login>totalbiscuit</login>
<title>SHOUTcraft</title>
<status>Showcraft - Monday/Wednesday 19:00 GMT - Vote Totalbiscuit King of the Web for charity! - http://tinyurl.com/votetotalbiscuit</status>
<tags/>
<producer>true</producer>
<category_title>Gaming</category_title>
<subcategory_title nil="true"/>
<producer>true</