这是我的代码,它解析 HTML 并将<small>
标签<span>
的出现替换为
String html =
"<html>"+
"<body bgcolor=''>"+
"<table class='tabletext'>" +
"<tr align='center' style='background:#FFFFFF'>" +
"<td class='classa'><span id='fd'><span>10</span></span></td>" +
"<td>10.00</td>" +
"<td><small>£0.00</small></td>" +
"<td>£280.00</td>" +
"<td>" +
"<ul>"+
"<li><a href=''>ok</a></li>"+
"</ul>"+
"<a href='/cart.php?action=add&qty=10&id=2628' title='Click here to add this item to your cart'>" +
"<img alt='Click here to add this item to your cart' src='/images/addtocart.gif' border='0' />" +
"</a>" +
"</td>" +
"</tr>" +
"<tr><td><span>Hello2</span></td></tr>"+
"</table>"+
"</body>"+
"</html>";
Document doc = Jsoup.parse(html);
Elements elements = doc.select("small");
Element element2 = elements.get(0);
System.out.println(element2.replaceWith("<span>"));
但是上面的代码不能正常工作。