相关疑难解决方法(0)

html敏捷包删除孩子

我在尝试删除具有特定ID的div及其子代使用HTML Agility包时遇到了困难.我确信我只是错过了一个配置选项,但它周五和我正在努力.

简化的HTML运行:

<html><head></head><body><div id='wrapper'><div id='functionBar'><div id='search'></div></div></div></body></html>
Run Code Online (Sandbox Code Playgroud)

这是我所拥有的.敏捷包抛出的错误表明它找不到div结构:

<div id='functionBar'></div>
Run Code Online (Sandbox Code Playgroud)

这是迄今为止的代码(取自Stackoverflow ....)

HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
        // There are various options, set as needed
        //htmlDoc.OptionFixNestedTags = true;

        // filePath is a path to a file containing the html
        htmlDoc.LoadHtml(Html);

        string output = string.Empty;

        // ParseErrors is an ArrayList containing any errors from the Load statement
        if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count > 0)
        {
            // Handle any parse errors as required

        }
        else
        {

            if (htmlDoc.DocumentNode != null)
            { …
Run Code Online (Sandbox Code Playgroud)

c# html-agility-pack

1
推荐指数
1
解决办法
7829
查看次数

标签 统计

c# ×1

html-agility-pack ×1