HTMLAgilityPack parse in the InnerHTML

前端 未结 1 1776
無奈伤痛
無奈伤痛 2020-12-21 16:08
Token1 Token2 Token3

I try to extract Token2 from the div

I manage to get To

1条回答
  •  盖世英雄少女心
    2020-12-21 16:48

    The text is in the text nodes; so you should be able to look at "//div/text()" and concatenate:

    StringBuilder sb = new StringBuilder();
    foreach (HtmlAgilityPack.HtmlTextNode node in
          doc.DocumentNode.SelectNodes("//div/text()"))
    {
        sb.Append(node.Text.Trim());
    }
    string s = sb.ToString();
    

    0 讨论(0)
提交回复
热议问题