I'm writing an app for a friend but I ran into a problem, the website has these
<span style="display:none">&0000000000000217000000</span>
And we have no idea even what they are, but I need them removed because my app is outputting their value.
Is there any way I can check to see if this is in the Elements and remove it? I have a for-each loop parsing however I cant figure out how to effectively remove this element.
thanks
If you want to remove those spans completely based on the style attribute, try this code:
String html = "<span style=\"display:none\">&0000000000000217000000</span>";
html += "<span style=\"display:none\">&1111111111111111111111111</span>";
html += "<p>Test paragraph should not be removed</p>";
Document doc = Jsoup.parse(html);
doc.select("span[style*=display:none]").remove();
System.out.println(doc);
Here is the output:
<html>
<head></head>
<body>
<p>Test paragraph should not be removed</p>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With