如何拆分字符串以字符串开头的字符串&#34; <input“=”“using =”“linq =”“in =”“c#=”“

时间:2017-01-10 10:25:44

标签: c# linq

=”“

下面提到的字符串是:

<table align="center" style="width: 800px;" border="0" cellspacing="1" cellpadding="1">
<tbody>
    <tr>
        <td id="litxt_1">Note : <input name="txt_1" tabindex="0" title="testTitle" disabled="disabled" id="txt_1" style="cursor: not-allowed; background-color: rgb(204, 204, 204);" type="text" size="100" value=""></td>
    </tr>
    <tr>
        <td style="text-align: center;"><u><span style="font-size: 18px;"><strong>Test Split<br>
        (Test Query)</strong></span></u></td>
    </tr>
    <tr>
        <td id="lichk_2">&nbsp;<input name="chk_2" tabindex="0" title="testTitle" disabled="disabled" id="chk_2" style="cursor: not-allowed; background-color: rgb(204, 204, 204);" type="checkbox" value="1" rel="#"></td>
    </tr>
    <tr>
        <td id="lichk_3">&nbsp;<input name="chk_3" tabindex="0" title="test Title" disabled="disabled" id="chk_3" style="cursor: not-allowed; background-color: rgb(204, 204, 204);" type="checkbox" value="1" rel="#"></td>
    </tr>
 </tbody>
</table>

现在在代码背后

string strAllline = File.ReadAllText("above html path");
string[] strResult = // strAllline.Split();

我正在尝试将结果放入数组strAllline.Split().Where(s => s.StartsWith("<input "))

2 个答案:

答案 0 :(得分:3)

我非常同意Tim Schmelter的评论。

使用HtmlAgilityPack,您可以使用3行代码执行此操作:

HtmlDocument doc =  new HtmlDocument();
doc.LoadHtml(t);
var strResult = doc.DocumentNode.Descendants("input").Select(d=>d.OuterHtml);

答案 1 :(得分:1)

var clients = Uow.Clients.AsNoTracking().where(x => x.zipCode= newZip);
var newClients = new List<Client>();
foreach (var client in clients)
{
    client.City = null;
    client.cityId = newCityId;
    newClients.Add(client);
}

Uow.Clients.AddMany(client);
Uow.Commit();

上面的代码给出了我想要的确切结果,任何人都可以将其转换为linq