使用HtmlAgilityPack如何加载编码的html字符串

使用HtmlAgilityPack如何加载编码的html字符串,html,html-agility-pack,Html,Html Agility Pack,我正在将html字符串转换为pdf。我目前正在使用ExpertPDF来完成此过程 但在这个过程中,我必须清理Html字符串,然后将清理后的Html字符串传递给将创建pdf的库 在清理过程中,第一步是删除不需要的html标记(比如从黑名单中删除标记。该列表将由我创建)。为了删除不需要的标记,我正在使用HtmlAgilityPack解析html字符串并删除节点 第二步是自动关闭打开的knows标记。当我使用HtmlAgilityPack加载html字符串时,它会自动关闭标记,这很好。但我在这里遇到了

我正在将html字符串转换为pdf。我目前正在使用ExpertPDF来完成此过程

但在这个过程中,我必须清理Html字符串,然后将清理后的Html字符串传递给将创建pdf的库

在清理过程中,第一步是删除不需要的html标记(比如从黑名单中删除标记。该列表将由我创建)。为了删除不需要的标记,我正在使用HtmlAgilityPack解析html字符串并删除节点

第二步是自动关闭打开的knows标记。当我使用HtmlAgilityPack加载html字符串时,它会自动关闭标记,这很好。但我在这里遇到了一个问题。问题是当有一些文本像“阅读<5然后去看医生”。小于符号将其视为标记的开始,然后在行的某个位置将其关闭

例如:下面是html

> <p style="margin-top: 5px; margin-bottom: 5px; line-height: 16.9px;
> background-color: #ffffff;">1. The full evaluation and management of
> acute coronary syndrome, ST-elevation and non-ST-elevation myocardial
> infarction is beyond the scope of SOC tele-intensivist coverage. 2.
> Early cardiology consultation should be recommended in all cases of
> suspected acute coronary syndrome or myocardial infarction 3. However,
> one of these syndromes is suspected, it is reasonable to recommend
> starting therapy with ASA, beta-blockers, nitrates, and morphine
> sulfate. 4. In addition, full dose anticoagulation with
> anticoagulation (e.g. unfractionated heparin, enoxaparin, or
> fondaparinux), second antiplatelet agent (e.g. clopidegrol) and
> initiation of statin therapy (atorvastatin 80 mg orally daily) should
> be considered 5. For patients with heart failure or ejection fraction
> < 40%, ACE-inhibitors (or ARB’s if history of ACE-inhibitors
> intolerance) should be considered. 6. Other more routine options are
> listed below.</p>

1。全面评估和管理 >急性冠脉综合征、ST段抬高和非ST段抬高心肌梗死 >梗死超出SOC远程强化治疗覆盖范围。2. >在所有心脏病患者中,应建议进行早期心脏病学咨询 >疑似急性冠状动脉综合征或心肌梗死3。然而, >其中一种综合征是可疑的,建议 >开始使用ASA、β受体阻滞剂、硝酸盐和吗啡进行治疗 >硫酸盐。4.此外,全剂量抗凝治疗 >抗凝(如普通肝素、依诺肝素或 >磺达肝素钠),第二抗血小板药物(如氯吡格雷)和 >开始他汀类药物治疗(阿托伐他汀80毫克,每日口服)应 >被认为是5。适用于心力衰竭或射血分数较高的患者 ><40%,ACE抑制剂(或ARB,如果有ACE抑制剂史 >不容忍)应予以考虑。6.其他更常规的选择包括 >如下所列

在使用HtmlAgilityPack并加载上述html和htmldocument节点后,将有一个outterxml,如下所示

> <p style="margin-top: 5px; margin-bottom: 5px; line-height: 16.9px;
> background-color: #ffffff;">1. The full evaluation and management of
> acute coronary syndrome, ST-elevation and non-ST-elevation myocardial
> infarction is beyond the scope of SOC tele-intensivist coverage. 2.
> Early cardiology consultation should be recommended in all cases of
> suspected acute coronary syndrome or myocardial infarction 3. However,
> one of these syndromes is suspected, it is reasonable to recommend
> starting therapy with ASA, beta-blockers, nitrates, and morphine
> sulfate. 4. In addition, full dose anticoagulation with
> anticoagulation (e.g. unfractionated heparin, enoxaparin, or
> fondaparinux), second antiplatelet agent (e.g. clopidegrol) and
> initiation of statin therapy (atorvastatin 80 mg orally daily) should
> be considered 5. For patients with heart failure or ejection fraction
> < 40%,="" ace-inhibitors="" (or="" arb’s="" if="" history="" of=""
> ace-inhibitors="" intolerance)="" should="" be="" considered.="" 6.=""
> other="" more="" routine="" options="" are="" listed=""></p>

1。全面评估和管理 >急性冠脉综合征、ST段抬高和非ST段抬高心肌梗死 >梗死超出SOC远程强化治疗覆盖范围。2. >在所有心脏病患者中,应建议进行早期心脏病学咨询 >疑似急性冠状动脉综合征或心肌梗死3。然而, >其中一种综合征是可疑的,建议 >开始使用ASA、β受体阻滞剂、硝酸盐和吗啡进行治疗 >硫酸盐。4.此外,全剂量抗凝治疗 >抗凝(如普通肝素、依诺肝素或 >磺达肝素钠),第二抗血小板药物(如氯吡格雷)和 >开始他汀类药物治疗(阿托伐他汀80毫克,每日口服)应 >被认为是5。适用于心力衰竭或射血分数较高的患者 ><40%,=“ace抑制剂=”“(或=”“arb's=“”如果=”“history=”“of=“” >血管紧张素转换酶抑制剂=“不耐受性)=“应考虑”。=“6.” >其他=“”更多=“”常规=“”选项=“”已列出=“”>

将<40%视为标记,并在结尾处关闭,将中间文本标记为属性

你能告诉我,为了将字符串加载到html文档中,并且不将<作为起始标记,我必须做些什么吗。有没有办法将文档作为编码文本而不是纯字符串文本加载

谢谢,
Raj.

请显示一些代码以复制问题。可能是您在HTMLAgilityPack中发现了一个bug,或者它对解析
的要求特别严格。您也应该尝试其他解析器,比如
AngleSharp
,也许您不会遇到这样的问题。请显示一些代码以复制该问题。可能是您在HTMLAgilityPack中发现了一个bug,或者它对解析
非常严格。您也应该尝试其他解析器,比如
AngleSharp
,也许您不会遇到这样的问题。