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
Java2
html tags
about java1
how to remove tags in HTML without functionalities? - Java Beginners
Using Core Tags, Html Tags
javaa swings - IDE Questions
How to store extracted values from xml in a database? - XML
How to store extracted values from xml in a database? - XML
how to print HTML using javascript or Jquery
Javah
how to write a jsp form using html
how to insert data in database using html+jsp
struts html tags - Struts
ModuleNotFoundError: No module named 'djangocms-html-tags'
ModuleNotFoundError: No module named 'djangocms-html-tags'
ModuleNotFoundError: No module named 'lektor-strip-html-tags'
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
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
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?
Style Tags Used in HTML
How to give value for select in HTML dynamically using javascript
Artifacts of commons-jelly-tags-html
How to populate an HTML table using jstl code - Spring
How you can escape a String for HTML using the StringEscapeUtils
How to Validate dynamically created text box in HTML using Javascript
Error in using jstl tags
how to save html form data into .csv file using only jsp.
Maven Dependency commons-jelly-tags-html >> 20040902.072530
Version of beehive>beehive-netui-tags-html dependency
Version of controlhaus>beehive-netui-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
Javap Tool application
How to pass and catch HTML parameters to a Java program using REST services?(without using servlet/jsp)
ModuleNotFoundError: No module named 'javax'
ModuleNotFoundError: No module named 'javax'
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
JSF HTML Tag Reference
javas - JSP-Servlet
Version of commons-jelly>commons-jelly-tags-html dependency
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?

Ads