使用html agility pack删除html标记之间的空格

使用html agility pack删除html标记之间的空格,html,c#-4.0,html-agility-pack,Html,C# 4.0,Html Agility Pack,接下来您应该尝试删除para或tag开头的前导空格。例如,你会发现许多类似的参考文献 <p class="MsoNoSpacing"><span style='font-size:12.0pt'> In these types of levers, the <i>fulcrum</i> F is in between the <i>effort </i>E and the <i>lo

接下来您应该尝试删除para或tag开头的前导空格。例如,你会发现许多类似的参考文献

<p class="MsoNoSpacing"><span style='font-size:12.0pt'>                In these
types of levers, the <i>fulcrum</i> F is in between the <i>effort </i>E and the
<i>load </i>L as shown in Fig 3.1 (a).</span></p>
在这些 对于杠杆类型,支点F位于作用力E和 荷载L如图3.1(a)所示

这应该转换为

<p class="MsoNoSpacing"><span style='font-size:12.0pt'>In these
types of levers, the <i>fulcrum</i> F is in between the <i>effort </i>E and the
<i>load </i>L as shown in Fig 3.1 (a).</span></p>
在这些 对于杠杆类型,支点F位于作用力E和 荷载L如图3.1(a)所示


我使用的是html agility pack,任何人都可以帮我解决这个问题。

html中元素之间的空白在渲染时会被压缩成一个空白。你能解释一下你为什么要做到这一点吗?你能解释一下你用HAP做了什么,你在哪里卡住了吗?我正在把一个docx文件转换成html文件,这导致了这个问题。现在我想解析这个文件,只要它发现一个空格,它就应该把它删除。使用HAP,我有下面的代码HTMLAGILITypack.HtmlNodeCollection bn=htmldoc.DocumentNode.SelectNodes(“//span”);foreach(bn中的HtmlAgilityPack.HtmlNode项){if(item.Attributes.ToString()=”style){string str=item.InnerText.ToString();int flag=1;char[]array=str.tocharray();for(int i=0;i