how html tags are extracted using java?

how html tags are extracted using java?

I would like to need the java code for extracting html tags.

View Answers

August 28, 2012 at 4:27 PM

Here is a java example that extract a tag from a line of HTML using the Pattern and Matcher classes.

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ExtractContentFromHTMLTag
{
  public static void main(String[] args)
  {
    String stringToSearch = "<p>Hello <h1>Welcome To Roseindia</h1> ...</p>";

    Pattern p = Pattern.compile("<h1>(\\S+)</h1>");
    Matcher m = p.matcher(stringToSearch);

    if (m.find()){
      String codeGroup = m.group(1);
      System.out.format("'%s'\n", codeGroup);
    }
  }
}









Related Tutorials/Questions & Answers:
how html tags are extracted using java?
how html tags are extracted using java?
Advertisements
difference between java5 and java6 - Java Beginners
html tags
Java2
about java1
Using Core Tags, Html Tags
how to remove tags in HTML without functionalities? - Java Beginners
javaa swings - IDE Questions
how to print HTML using javascript or Jquery
How to store extracted values from xml in a database? - XML
How to store extracted values from xml in a database? - XML
Javah
struts html tags - Struts
how to write a jsp form using html
ModuleNotFoundError: No module named 'djangocms-html-tags'
ModuleNotFoundError: No module named 'lektor-strip-html-tags'
ModuleNotFoundError: No module named 'djangocms-html-tags'
how to insert data in database using html+jsp
Version of commons-jelly-tags-html>commons-jelly-tags-html dependency
How to export data from html to excel sheet by using java
how to validate the telephone number without using jquery in html with javascript
How to export data from html file to excel sheet by using java
Maven Repository/Dependency: commons-jelly-tags-html | commons-jelly-tags-html
How to export data from html file to excel sheet by using java
how to convert doc file into html using java swing
About Java2
Artifacts of commons-jelly-tags-html
Style Tags Used in HTML
how to update values of a html form into an excel table using java servlets?
how to load values of html form into an excel table using java servlet?
How to give value for select in HTML dynamically using javascript
Error in using jstl tags
How to populate an HTML table using jstl code - Spring
Maven Dependency commons-jelly-tags-html >> 20040902.072530
How you can escape a String for HTML using the StringEscapeUtils
Version of beehive>beehive-netui-tags-html dependency
Version of controlhaus>beehive-netui-tags-html dependency
How to Validate dynamically created text box in HTML using Javascript
how to save html form data into .csv file using only jsp.
How to pass and catch HTML parameters to a Java program using REST services?(without using servlet/jsp)
Javap Tool application
JSF HTML Tag Reference
Maven dependency for beehive - beehive-netui-tags-html version 1.0-alpha is released. Learn to use beehive-netui-tags-html version 1.0-alpha in Maven based Java projects
using xml and html in xcode project
Version of commons-jelly>commons-jelly-tags-html dependency
Maven dependency for com.gooddata - gooddata-http-client version 1.0.0+java7 is released. Learn to use gooddata-http-client version 1.0.0+java7 in Maven based Java projects
how to retrieve image from mysql database using java and show it in HTML img tag ?
How to play FLV video files on Ipad using HTML code or javascript code?
Html form validation using jquery

Ads