2014-09-24 42 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