Htmlagilitypack不转换标签

本文关键字:标签 转换 Htmlagilitypack | 更新日期: 2023-09-27 18:15:21

我不转换为HTMLAgilityPack标签。我如何使转换的值?

通过这种方式,我想得到一个输出

Yayın Tarihi:13.09.2015—g ncelleme Tarihi:18.09.2015

<ul class="DefaultAspxWebParcasi">
  <li>
    <a href="http://www.e-saglik.gov.tr/belge/1-44068/ozel-saglik-kurum-ve-kuruluslari-tarafindan-saglik-net-.html">
      <i> -Yayın Tarihi</i>
      : 18.09.2015 /
      <i> Güncellenme Tarihi</i>
      : 18.09.2015
  </li>
  <li>
    <a href="http://www.e-saglik.gov.tr/belge/1-42578/sagliknet-sistemi-2-ve-3-basamak-veri-gonderimi-ile-ilg-.html">
      <i> -Yayın Tarihi</i>
      : 13.08.2015 /
      <i> Güncellenme Tarihi</i>
      : 18.09.2015
  </li>

c#代码。

WebClient wc = new WebClient();
            wc.Encoding = Encoding.UTF8;
            string data = wc.DownloadString(Link());
            HtmlAgilityPack.HtmlDocument doc = new  HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(data);
            HtmlAgilityPack.HtmlNodeCollection icCont2 = doc.DocumentNode.SelectNodes(@"//ul[@class='DefaultAspxWebParcasi']//li//a");
foreach (HtmlAgilityPack.HtmlNode item in icCont2)
                {
                    string iler = item.SelectSingleNode("//i").InnerHtml.ToString();
                    Console.WriteLine(iler);
                }

Htmlagilitypack不转换<i>标签

下面的代码将生成-Yayın Tarihi: 18.09.2015/g ncellenme Tarihi: 18.09.2015。希望对大家有所帮助。

           var doc = new HtmlDocument();
            doc.LoadHtml(data);
            HtmlAgilityPack.HtmlNodeCollection icCont2 = doc.DocumentNode.SelectNodes(@"//ul[@class='DefaultAspxWebParcasi']//li//a");
            foreach (HtmlAgilityPack.HtmlNode item in icCont2)
            {
                Regex trimmer = new Regex(@"'s's+");
                var iler = trimmer.Replace(item.InnerText, " ");
                Console.WriteLine(iler);
            }