C# 如何拆分字符串以“开始”开头的字符串&书信电报;输入“;在c中使用linq#
下面提到的字符串是:C# 如何拆分字符串以“开始”开头的字符串&书信电报;输入“;在c中使用linq#,c#,linq,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="
<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"> <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"> <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>
我试图在数组
strAllline.Split()中得到结果,其中(s=>s.StartsWith(“我非常同意Tim Schmelter的评论。
使用HtmlAgilityPack,您可以使用3行代码完成此操作:
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(t);
var strResult = doc.DocumentNode.Descendants("input").Select(d=>d.OuterHtml);
我非常同意Tim Schmelter的评论。
使用HtmlAgilityPack,您可以使用3行代码完成此操作:
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(t);
var strResult = doc.DocumentNode.Descendants("input").Select(d=>d.OuterHtml);
string[]result=renderHTML.Split('\n');
字符串strInput=“”;
字符串strFinal=“”;
foreach(结果中的var项目)
{
if(item.Contains)(“string[]result=renderHTML.Split('\n');
字符串strInput=“”;
字符串strFinal=“”;
foreach(结果中的var项目)
{
if(item.Contains)(“不要试图用正则表达式甚至纯字符串方法解析(或拆分)HTML。使用像@TimSchmelter这样的HTML解析器,我能问一下原因吗?只是好奇。xml解析更能保持父子关系和数组结构。@Badiparmagi:解析有效的HTML(甚至是自生成的)是可能的,并且可以用正则表达式(甚至字符串方法)解决。但是用正则表达式解析任意(X)HTML/CSS/DOM是不可能的,因为它不是一种常规语言。你知道吗?@TimSchmelter感谢你的回复。不要尝试解析(或拆分)带有正则表达式甚至纯字符串方法的HTML。使用像@TimSchmelter这样的HTML解析器我能问一下原因吗?只是好奇。xml解析更能保持父子关系和数组结构。@Badiparmagi:解析有效的HTML(甚至是自生成的)是可能的,可以用正则表达式(甚至字符串方法)解决。但是用正则表达式解析任意(X)HTML/CSS/DOM是不可能的,因为它不是一种常规语言。你知道吗?@TimSchmelter谢谢你的回答。@Maksim Simkin&…,假设我们在上表中有字符串变量?那是字符串变量。:-)@Maksim Simkin&…,假设上表中有字符串变量?即字符串变量。:-)
string[] result = renderHTML.Split('\n');
string strInput = "";
string strFinal = "";
foreach (var item in result)
{
if (item.Contains("<input"))
{
int indexOfSteam = item.IndexOf("<input");
strInput = item.Remove(0, indexOfSteam);
strInput = strInput.Replace("<td>", "");
strInput = strInput.Replace("</td>", "");
strFinal += strInput + "|";
strInput = "";
}
}
string[] controls = strFinal.Split('|');