Logo

Winista.HtmlParser 运用一则

photo

2022年07月25日

using Winista.Text.HtmlParser;
using Winista.Text.HtmlParser.Lex;
using Winista.Text.HtmlParser.Util;
using Winista.Text.HtmlParser.Tags;
using Winista.Text.HtmlParser.Filters;

 

 string HtmlText(string sourceHtml)
{
            Parser parser = Parser.CreateParser(sourceHtml.Replace(System.Environment.NewLine,””), “utf-8”);

            StringBuilder builderHead = new StringBuilder();
            StringBuilder builderBody = new StringBuilder();

            NodeFilter html = new TagNameFilter(“HTML”);
            INode nodes = parser.Parse(html)[0];
            builderHead.Append(nodes.Children[0].ToHtml());
            INode body = nodes.Children[1];
            INode div = body.Children[0];

            for (int i = 0; i < div.Children.Count; i++)
            {
                if (div.Children[i] is ITag)
                               builderBody.Append(div.Children[i].ToHtml());
            }

            StringBuilder builder = new StringBuilder();
            builder.Append(“<html>”);
            builder.Append(builderHead.ToString());
            builder.Append(“<body>”);
            builder.Append(string.Format(“<{0}>”,div.GetText()));
            builder.Append(builderBody.ToString());
            builder.Append(“</div>”);
            builder.Append(“</body>”);
            builder.Append(“</html>”);
            return builder.ToString();
        }

橙子主题打折出售

其实我不卖,主要是这里是放广告的,所以就放了一个
毕竟主题都没做完,卖了也是坑.

购买它
所有附件
该文章没有附件.
本文为原创文章,请注意保留出处!

热门文章

ffmpeg 生成水印 1:先要配置ffmpeg的滤镜:参考:https://www.jianshu.com/p/9d24...ffmpeg生成水印 作者:Pastore Antonio
1532 浏览量
Navicat Premium 12.0.22 安装与破解 一、安装  NavicatPremium12.0.22的下载链接:https://pan.ba...NavicatPremium12.0.22安装与破解 作者:Pastore Antonio
1474 浏览量
谷歌浏览器扩展程序报错 The message port closed before a response was received. 问题描述ChromeExtension报错:Uncheckedruntime.lastEr...谷歌浏览器扩展程序报错Themessageportclosedbeforearesponsewasreceived. 作者:Pastore Antonio
1469 浏览量
Spring Aop AfterReturning接收返回值 包结构:Spring.xmlUserDao.java测试类Main方法...SpringAopAfterReturning接收返回值 作者:Pastore Antonio
1464 浏览量
CentOS 系统yum安装出现“未找到匹配的参数”、“没有可用软件包”错误的解决办法 帮助文档链接:https://www.opsit.cn/4896.html今天安装fwknop时,...CentOS系统yum安装出现“未找到匹配的参数”、“没有可用软件包”错误的解决办法 作者:Pastore Antonio
1459 浏览量