返回首页

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</producer>

    <language>en</language>

    <timezone>Europe/London</timezone>

    <channel_url>http://www.justin.tv/totalbiscuit</channel_url>

    <mature nil="true"/>

    <image_url_huge>http://static-cdn.jtvnw.net/jtv_user_pictures/totalbiscuit-profile_image-e1a17a8ba4a361e3-600x600.png</image_url_huge>

    <image_url_large>http://static-cdn.jtvnw.net/jtv_user_pictures/totalbiscuit-profile_image-e1a17a8ba4a361e3-300x300.png</image_url_large>

    <image_url_medium>http://static-cdn.jtvnw.net/jtv_user_pictures/totalbiscuit-profile_image-e1a17a8ba4a361e3-150x150.png</image_url_medium>

    <image_url_small>http://static-cdn.jtvnw.net/jtv_user_pictures/totalbiscuit-profile_image-e1a17a8ba4a361e3-70x70.png</image_url_small>

    <image_url_tiny>http://static-cdn.jtvnw.net/jtv_user_pictures/totalbiscuit-profile_image-e1a17a8ba4a361e3-50x50.png</image_url_tiny>

    <screen_cap_url_huge>http://static-cdn.jtvnw.net/previews/live_user_totalbiscuit-630x473.jpg</screen_cap_url_huge>

    <screen_cap_url_large>http://static-cdn.jtvnw.net/previews/live_user_totalbiscuit-320x240.jpg</screen_cap_url_large>

    <screen_cap_url_medium>http://static-cdn.jtvnw.net/previews/live_user_totalbiscuit-150x113.jpg</screen_cap_url_medium>

    <screen_cap_url_small>http://static-cdn.jtvnw.net/previews/live_user_totalbiscuit-70x53.jpg</screen_cap_url_small>

    <embed_enabled>true</embed_enabled>

    <embed_code>    <object type="application/x-shockwave-flash" height="295" width="353" id="live_embed_player_flash" data="http://www.justin.tv/widgets/live_embed_player.swf?channel=totalbiscuit" bgcolor="#000000"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.justin.tv/widgets/live_embed_player.swf" /><param name="flashvars" value="start_volume=25&channel=totalbiscuit&auto_play=false" /></object>

    </embed_code>

    <views_count><& get mongo users.totalbiscuit.views_count 0 &></views_count>

    </channel>

    <broadcaster>fme</broadcaster>

    <video_codec>AVC</video_codec>

    <channel_view_count>10627022</channel_view_count>

 </stream>

</streams>

这只能说明这个XML流时是活的。当它不活,所有XML文件中存在的是:

{体C3}
我的问题是,如何我可以用我上面的方法读取XML读取这个XML文件?所有我需要做的是阅读文件,如果发现
<results/>
,然后根据我的代码,它为脱机。如果我没有找到它(或者更确切地说,找到{碳五}),这将意味着它是网上的。但我怎么做,我做我的代码相同的方式呢?任何帮助将不胜感激。

回答