• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTML Table  RSS feed

 
vinoth Robert
Ranch Hand
Posts: 32
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Is there any way to get all the contents of a HTML table from action page?
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Retrieve the HTML, then parse it.
 
Ram Mullangi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vinoth Robert,

download jericho-html-3.2.jar file and place this jar file in your class path. Then execute the following code to extract table content in html file.

String sourceUrlString=null;
sourceUrlString="file:///D://Temp/test.html";
if (sourceUrlString.indexOf(':')==-1) sourceUrlString="file:"+sourceUrlString;
MicrosoftConditionalCommentTagTypes.register();
PHPTagTypes.register();
PHPTagTypes.PHP_SHORT.deregister(); // remove PHP short tags for this example otherwise they override processing instructions
MasonTagTypes.register();
Source source=new Source(new URL(sourceUrlString));
List<Element> linkElements=source.getAllElements(HTMLElementName.TD);
for (Element linkElement : linkElements) {
String label=linkElement.getContent().getTextExtractor().toString();
System.out.println(label);
}

-Ram
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!