How to remove a specific tag from the entire html page using jsoup

Jalal Sordo

i'm using jsoup 1.7.3 to edit some html files.

what i need is to remove the following tags from the html file :

<meta name="GENERATOR" content="XXXXXXXXXXXXXX">
<meta name="CREATED" content="0;0">
<meta name="CHANGED" content="0;0">

As you see its the tag, how can i do that, here what i've tried so far :

//im pretty sure that the <meta> tag is nested in the <header>
but removing the whole  header is bad practice.

Document docsoup = Jsoup.parse(htmlin);
docsoup.head().remove();

what do you suggest ?

djvazquez

I recommend you use Jsoup selectors, for example

Document document = Jsoup.parse(html);
Elements selector = document.select("meta[name=GENERATOR]");

for (Element element : selector) {
    element.remove();
}

doc.html(); // returns String html with elements removed

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to remove a specific tag from the entire html page using jsoup

From Dev

JSoup Not Transversing Entire HTML Page

From Dev

Using jquery remove style tag from html page

From Dev

How to get a specific data from the <SCRIPT> tag in HTML page using Javascript

From Dev

remove specific text from html page using jquery

From Dev

How to remove script tag from html using javascript

From Dev

How to remove all inline styles and other attributes from html elements using Jsoup?

From Dev

How to remove all inline styles and other attributes from html elements using Jsoup?

From Dev

How to extract text outside of a html tag using jsoup?

From Dev

How to remove <script> tags from an HTML page using C#?

From Dev

Remove html tag from a string using jQquery

From Dev

Jsoup CSS tag deep in an html page

From Dev

Extract text from html string using Jsoup with specific encoding

From Dev

how to extract "value" from a table tag using class name with jsoup

From Dev

Jsoup not downloading entire page

From Dev

Jsoup not downloading entire page

From Dev

How to remove only html tags from text with Jsoup?

From Dev

How to remove HTML Entities in Jsoup?

From Dev

How to remove tag style from html

From Dev

How to check and remove html tag from string

From Dev

How to scrape and download the table in HTML page using JSOUP through java

From Dev

Jsoup how to get text from a specific column of an html table

From Dev

How to retrieve a code snippet from html page with Jsoup?

From Dev

How to retrieve a code snippet from html page with Jsoup?

From Dev

TSQL remove img tag with specific src from HTML

From Dev

How to add html page to another html page by using object tag?

From Dev

How to extract multiple email addresses from a web page using Jsoup?

From Dev

Remove all instances of a specific XML tag from a string using regex

From Dev

How to goto specific tag with some specific attribute in html using perl?

Related Related

  1. 1

    How to remove a specific tag from the entire html page using jsoup

  2. 2

    JSoup Not Transversing Entire HTML Page

  3. 3

    Using jquery remove style tag from html page

  4. 4

    How to get a specific data from the <SCRIPT> tag in HTML page using Javascript

  5. 5

    remove specific text from html page using jquery

  6. 6

    How to remove script tag from html using javascript

  7. 7

    How to remove all inline styles and other attributes from html elements using Jsoup?

  8. 8

    How to remove all inline styles and other attributes from html elements using Jsoup?

  9. 9

    How to extract text outside of a html tag using jsoup?

  10. 10

    How to remove <script> tags from an HTML page using C#?

  11. 11

    Remove html tag from a string using jQquery

  12. 12

    Jsoup CSS tag deep in an html page

  13. 13

    Extract text from html string using Jsoup with specific encoding

  14. 14

    how to extract "value" from a table tag using class name with jsoup

  15. 15

    Jsoup not downloading entire page

  16. 16

    Jsoup not downloading entire page

  17. 17

    How to remove only html tags from text with Jsoup?

  18. 18

    How to remove HTML Entities in Jsoup?

  19. 19

    How to remove tag style from html

  20. 20

    How to check and remove html tag from string

  21. 21

    How to scrape and download the table in HTML page using JSOUP through java

  22. 22

    Jsoup how to get text from a specific column of an html table

  23. 23

    How to retrieve a code snippet from html page with Jsoup?

  24. 24

    How to retrieve a code snippet from html page with Jsoup?

  25. 25

    TSQL remove img tag with specific src from HTML

  26. 26

    How to add html page to another html page by using object tag?

  27. 27

    How to extract multiple email addresses from a web page using Jsoup?

  28. 28

    Remove all instances of a specific XML tag from a string using regex

  29. 29

    How to goto specific tag with some specific attribute in html using perl?

HotTag

Archive