Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6981807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:12:18+00:00 2026-05-27T18:12:18+00:00

I need to perform several action on a html file such as removing a

  • 0

I need to perform several action on a html file such as removing a specific tag or delete attributes. I decided to use HTML Parser, a java library:
http://htmlparser.sourceforge.net/

First of all, I want to remove all the style tags. I managed to get a NodeList containing all the styles tag by doing this:

Parser parser = new Parser (url);
NodeList list = parser.parse (null);            
NodeList styles = list.extractAllNodesThatMatch (new TagNameFilter ("STYLE"), true);

Now I don’t know how to delete this style attributes from the whole list of nodes. Do I have to fetch the whole list?

After that, I want to be able to delete all the attributes inside the tags or delete only the alt attributes for example. Is there a method which does that automatically?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:12:19+00:00Added an answer on May 27, 2026 at 6:12 pm

    From the documentation, the Parser returns a list of trees that contains all of your html’s nodes (think of the parser as the root node of a big tree of Node and each “level” of that tree is a NodeList).

    You can iterate through the tree recursively, test each node’s type against StyleTag and delete it from the appropriate NodeList when applicable. Keep descending into the tree recursively until you visit all its nodes.

    NodeTreeWalker is your friend and can help you with the recursive tree traversal.

    jsoup is another nice alternative that has a simpler interface (see this other question).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to perform some action when my application receives focus. I've tried hooking
I need to perform an action after a session times out. However I have
In my current iOS app, I need to perform several network operation when the
I need to perform several copy commands on a remote location (using ssh cp
I need to perform several operations on a list of windows (minimize some of
I want to perform the title-named action under linux command-line(several ca bash script will
On a page, I have several elements on which I need to perform repetitive
I need to perform several post-validations in a Symfony form. First time I came
Let's suppose I need to perform some average-length (several days) refactoring. I create mybranch
I need to perform an action if someone uses the wheel when the mouse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.