我将网页的内容加载到字符串中。我想要提取的唯一值是这样的:
>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)
{
}
}
}
}
关于如何提取与排名相关联的团队名称的任何想法?
答案 0 :(得分: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
}