0

我从 ChildNode.InnerHtml 中得到值

20th Aug 2013<br>Ojas Systems <br> Pune <br> Software

如何通过 HtmlAgilty 从生成的 InnerHtml 中拆分值。我尝试将 InnerHtml 转换为字符串,但它会引发错误

方法 'Write' 没有重载需要 0 个参数

可能是因为未关闭的 html 标签,但可能是解决方案下面是返回的 InnerHtml

<a href="http://jobs.monsterindia.com/details/13826093.html?sig=js-1- 4f08ba3c3102de443076cfb01e15745e-1&from=" target="_blank" id="link13826093">.Net java </a>, 20th Aug 2013<br>Ojas Systems Private Limited<br> Pune, 0-0 years: Looking for freshers who is trained in .Net Java.The location will be Pune.Preferably passed in 2012-2013. <br><a href="javascript:findSimilar(13826093)">Similar Jobs</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="http://jobsearch.monsterindia.com/searchresult.html?cid=117314;lan=1">All Jobs by this Recruiter</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="javascript:void(0)" onclick="javascript:openSocialTwist({EXP:'Experience - 0 to 0 years',LINK:'http://jobs.monsterindia.com/details/13826093.html',COMP:'Company Name - Ojas Systems Private Limited',LOC:'Location - Pune',ROLE:'',KWD:'Key skills - .net java',TTL:'Job Title - .Net java '})">Share this job</a>
4

3 回答 3

3

采取形式在这里 为我工作

string str = "hai<br/>how<br/>Are<br/>you";

            string[] delim = { "<br/>" };

            string[] spltd = str.Split(delim, StringSplitOptions.None);
于 2016-04-02T14:50:06.703 回答
0

如果您能够检索 ChildNode.InnerHtml 您也应该能够将其保存为字符串:

string inner_html = ChildNode.InnerHtml.ToString();

您可以<br>用“/”或其他字符(inner_html .replace("<br>,"/"))替换,然后在“/”字符上使用简单的字符串拆分

编辑

如果 innerhtml 将始终采用相同的格式,您可以使用类似这样的内容

string[] delimiter = new string[] {"<br>"};
string inner_html = ChildNode.InnerHtml.ToString();
int i = inner_html.IndexOf("</a>");
if( i!=-1)
{
   int j = inner_html.IndexOf("<a", i + 4);
   if (j != -1)
   {

      string yourStr = inner_html.Substring(i + 4,j);
      string[] splitedStr = yourStr.split(delimiter, StringSplitOptions.RemoveEmptyEntries); 
   }
}
于 2013-09-20T05:37:21.443 回答
0
string input = "20th Aug 2013<br>Ojas Systems <br> Pune <br> Software";
string[] result = input.Split(new string[]{"<br>"}, StringSplitOptions.None);

输出

20th Aug 2013 
Ojas Systems  
 Pune  
 Software 
于 2013-09-20T05:48:20.657 回答