Skip to main content

Help with html tags in java

1 reply [Last post]
Joined: 2010-02-02


I'm writing a program and I have a problem. I want to read text between html tags. eg:
Some text .
Any idea how to do this?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-10-25

You could use javax.xml.parsers.DocumentBuilder. From the API, [i]"An instance of this class can be obtained from the DocumentBuilderFactory.newDocumentBuilder()"[/i].

Then parse out a new DOM Document object - Document is an Interface.

Next I would get an Element type object, then a NodeList type object, in which you want to end up with a Node.

The Node type object contains several methods to extract or manipulate the text between tags.