Replace HTML tags using jsoup

后端 未结 1 1264
不思量自难忘°
不思量自难忘° 2021-02-14 00:49

Here is my code

String html = \"fsdfsdfsdfdasdasd\";
Document doc = Jsoup.parse(html);
Elements elements = doc.         


        
相关标签:
1条回答
  • 2021-02-14 01:22

    You can replace the Tag like this too:

    String html = "<font>fsdfs<font>dfsdf</font>dasdasd</font>";
    Document doc = Jsoup.parse(html);
    Elements elements = doc.select("font");
    
    
    // rename all 'font'-tags to 'span'-tags, will also keep attributs etc.
    elements.tagName("span");
    
    System.out.println(doc.html());
    
    0 讨论(0)
提交回复
热议问题