0

我将网页的内容加载到字符串中。我要提取的唯一值是这样的:

>1<    >Goons<
>2<    >Worms<
>3<    >Hampsters<
>4<    >Clouds<

数值总是按顺序排列的,但是团队名称会每天更改...我想提取每个团队的排名并将它们存储到数据库中。

到目前为止,我编写了一个将传入 URL 的函数:

 protected void HandleURL(string teamsURLFile)
    {
        string searchValue = null; 

        string[] teams = new string[32] { "BirdDogs","Piegons","Ducks","Badgers","Clouds","Ghosts","Clowns","Kitties",
                                          "Socks","Farrets","Lions","Chumps","HillBillys","Goons","Dragons","Hampsters",
                                          "Fish","SeaBirds","Snakes","Mules","Spiders","Goats","Worms","Bafoons",
                                          "Magpies","Donkeys","65ers","Rockts","Rams","Hampsters","Tubbies","Plumpers"};



        for (int i = 0; i < 32; i++)
        {
            if (teamsURLFile.Contains(">" + i + "<"))
            {
                foreach (string teamName in teams)
                {

                }
            }
        }

    }

关于如何提取与排名相关的团队名称的任何想法?

4

1 回答 1

1

这样做: -

for (int i = 0; i < 32; i++)
        {
           string val=">" + i + "<";
           int start= teamsURLFile.IndexOf(val);               
           start = s.IndexOf(">",start+val.length);
           int end = s.IndexOf("<",start);
           string team= s.Substring(start, end - start -1);
           //do whatever you want to do with team  

        }
于 2012-08-19T21:36:20.713 回答