html img结构因输入而异

时间:2014-12-20 14:47:48

标签: jsoup

当我在javascript中添加下面的代码行时,img结束标记就会消失

Jsoup = org.jsoup.Jsoup;
doc = Jsoup.parse(html);

来源数据:

<div class="col-sm-3"><a title="Microsemi's Ultra-secure SmartFusion2 SoC FPGAs and IGLOO2 FPGAs Recognized on EDN's List of Hot 100 Products of 2014" href="http://www.prnewswire.com/news-releases/microsemis-ultra-secure-smartfusion2-soc-fpgas-and-igloo2-fpgas-recognized-on-edns-list-of-hot-100-products-of-2014-300010576.html" ><img class="list-image" src="http://photos.prnewswire.com/prnthumb/20110909/MM66070LOGO" border="0" alt="Microsemi Corporation." id="img0" /></a></div>

目标数据我通过上面的两行来获得:

<div class="col-sm-3"> 
     <a title="Microsemi's Ultra-secure SmartFusion2 SoC FPGAs and IGLOO2 FPGAs Recognized on EDN's List of Hot 100 Products of 2014" href="http://www.prnewswire.com/news-releases/microsemis-ultra-secure-smartfusion2-soc-fpgas-and-igloo2-fpgas-recognized-on-edns-list-of-hot-100-products-of-2014-300010576.html"> <img src="http://photos.prnewswire.com/prnthumb/20110909/MM66070LOGO" alt="Microsemi Corporation."> </a> 
    </div>

任何建议如何解决它。在上面的目标img结束标记丢失。那我怎么解决呢。

1 个答案:

答案 0 :(得分:1)

<div class="col-sm-3"><a title="Microsemi's Ultra-secure SmartFusion2 SoC FPGAs and IGLOO2 FPGAs Recognized on EDN's List of Hot 100 Products of 2014" href="http://www.prnewswire.com/news-releases/microsemis-ultra-secure-smartfusion2-soc-fpgas-and-igloo2-fpgas-recognized-on-edns-list-of-hot-100-products-of-2014-300010576.html" >

<img id="img0" class="list-image" src="http://photos.prnewswire.com/prnthumb/20110909/MM66070LOGO" border="0" alt="Microsemi Corporation."/></a></div>