2014-09-24 121 views
0

有没有简单的方法来纠正错误解释的html标签? 例如:我有一个HTML文件以下文字:错误的html标签

<div class=paragraph style=" padding:0.00pt 18.48pt 0.00pt 19.68pt; text-align:left;"><span class=font29 style=" line-height:10.56pt;">Here is some text. and here comes a <wrongly interpreted html-tag> how can the "<" and ">" be removed?</span></div> 

我如何可以提取并纠正一切错误地解释html标签? 我想到了一个列表,我添加了所有“正确的”html标签。但我不知道这是否会工作...

感谢您的任何帮助! :)

+2

不要做无效的标记在首位。在文字中使用'<'和'>'而不是'<' and '>'。一旦你打破了一个鸡蛋,很难将它塞回壳中。 – Amadan 2014-09-24 08:56:49

+0

嗯,事情是,我所有的文件包含已经“<" and ">”... – MarkF6 2014-09-24 09:49:58

回答

0

您应该使用HTML entities。例如<应该用HTML编写为&lt;(小于)和>作为&gt;(大于)。然后

你的字符串看起来像:

<div><span>Here is some text. and here comes a &lt;wrongly interpreted html-tag&gt; how can the "&lt;" and "&gt;" be removed?</span></div> 
+0

但问题是,我的文件已经包含这些错误的HTML标签 - 这是修道院精读者的错误:( – MarkF6 2014-09-24 09:51:23

+0

在这种情况下,一个与Abbyy的错误报告,并同时找到另一个转换工具。Google在“PDF到HTML”方面的结果并不缺。 – Amadan 2014-09-25 00:31:25

+0

嗯,这又如何:我搜索所有出现的“<”,它们是没有跟着“class”或“/”[这里,列表对于所有有效标签都是很好的]。找到的例子中的所有“<”应该被移除。 我认为这应该起作用... so ,我的(最终?)问题是:这个想法的可能实现将如何? – MarkF6 2014-09-25 08:50:40