0
我有以下的代碼,從XML得到的img標籤的URL這是正常工作:獲取的img標籤
Pattern p = Pattern.compile("<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>");
Matcher m = p.matcher(xmlString);
while (m.find())
imagesURLs.add(m.group(1));
我的XML如下所示:
<item>
<desc>
txt txt txt txt <img src="htttp://mysite.com/images/img.png"> txt txt
<img src="htttp://mysite.com/images/img.png"> ...
</desc>
</item>
<item>
<desc>
txt txt txt txt <img src="htttp://mysite.com/images/img.png"> txt txt
<img src="htttp://mysite.com/images/img.png"><img src="htttp://mysite.com/images/img.png">
</desc>
</item>
我想要修改代碼以僅從每個desc標籤獲取第一個img標籤url。
使用合適的xml解析器 – epoch
我在其他地方需要xml中的所有數據。但不是當我只需要主頁上的圖像時,我想讓它們在主頁按鈕後面逐一播放。 – hasan83
因此,如果您的代碼庫中已經有適當的XML解析器,那麼爲什麼要重新發明輪子? –