在我的應用程序中,我必須修復<img>
標記的所有結束標記,如下所示。 <img>
與>
關閉,而不是/>
。如何搜索和更正html標籤和屬性?
有什麼簡單的方法可以在本文中搜索所有<img>
並修復>
?
(如果已關閉/>
,則不需要執行任何操作)。
其他問題,如果指定<img>
沒有「寬度」或「高度」,解決此問題的最佳方法是什麼?
下載所有圖像並獲取寬度和高度的相應屬性,然後將它們添加回字符串?
正確的<img>
標記是以/>
關閉並具有有效寬度&高度的標記。
<a href="http://www.cultofmac.com/daily-deals749-mac-mini-1199-3-0ghz-imac-new-mac-pros/52674"><img align="left" hspace="5" width="150" src="http://s3.dlnws.com/images/products/images/749000/749208-large" alt="" title=""></a>
Apple today unleashed a number of goodies, including giving iMacs and Mac Pros more oomph with new processors and increased storage options. We have those deals today, along with many more items for the Mac lover. Along with the refreshed line of iMacs and Mac Pros, we’ll also look at a number of software deals [...]
<p><a href="http://feedads.g.doubleclick.net/~a/DL_-gOGSR1JMzKDbErt1EG3re3I/0/da"><img src="http://feedads.g.doubleclick.net/~a/DL_-gOGSR1JMzKDbErt1EG3re3I/0/di" border="0" ismap></a><br>
<a href="http://feedads.g.doubleclick.net/~a/DL_-gOGSR1JMzKDbErt1EG3re3I/1/da"><img src="http://feedads.g.doubleclick.net/~a/DL_-gOGSR1JMzKDbErt1EG3re3I/1/di" border="0" ismap></a></p><img src="http://feeds.feedburner.com/~r/cultofmac/bFow/~4/Mq5iLOaT50k" height="1" width="1">
你到底在做什麼? – JohnB 2010-07-27 18:04:26
我使用Three20庫中的TTStyledTextLabel將解析的文本顯示到視圖中,並且因爲文本沒有以正確的格式顯示,所以我需要在傳遞到StyledText之前對其進行更正。 – 2010-07-27 22:21:26