java - Jsoup cleaning my html -


i'm trying learn how use jsoup cleaning html code.

i want remove <body> tag example <p> tag must stay:

public class prb {     public static void main(string[] args) throws exception {         string = "<p>text 1234 <body>wow</body> text 1234</p><p>text 1234</p>";          system.out.println(getstringwithouthtmltags(i));     }      public static string getstringwithouthtmltags(string text) {         whitelist asd = new whitelist();         asd.addtags("<p>", "</p>");         asd.removetags("<body>, </body>");          return jsoup.clean(text, asd);     } } 

but removes tags. output is:

text 1234 wow text 1234 text 1234

what doing wrong?

thank in advance.

you made mistake on writing tags, because asd.addtags("<p>", "</p>"); heavy because have twice p , <,>,/ useless

so documentation says :

asd.addtags("p"); asd.removetags("body"); 

more details on tags/attributes/procotols whitelist : jsoup whitelist


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -