Module com.renomad.minum
Package com.renomad.minum.htmlparsing
package com.renomad.minum.htmlparsing
Converts HTML text into a Java data structure. It processes quickly, and can provide
an ability to search for HTML elements by attributes.
Here is an example of a test exercising the parser:
@Test
public void test_HtmlParser_Details1() {
String input = "<br foo=bar />";
var expected = List.of(
new HtmlParseNode(
ParseNodeType.ELEMENT,
new TagInfo(TagName.BR, Map.of("foo", "bar")),
List.of(),
""));
List<HtmlParseNode> result = new HtmlParser().parse(input);
assertEquals(expected, result);
}
Some of the testing library depends on this framework, such
as FunctionalTesting.TestResponse.searchOne(com.renomad.minum.htmlparsing.TagName, java.util.Map)
.
This is heavily used in the tests on Minum, as well as being available to applications, such as
this example from the Memoria project:
logger.test("GET the detail view of a person");
{
var response = ft.get("person?id=" + personId);
assertEquals(response.searchOne(TagName.H2, Map.of("class","lifespan-name")).innerText().trim(), "John Doe");
assertEquals(response.searchOne(TagName.SPAN, Map.of("class","lifespan-era")).innerText().trim(), "November 14, 1917 to March 19, 2003");
}
-
ClassDescriptionRepresents the expected types of things we may encounter when parsing an HTML string, which for our purposes is
ParseNodeType
.Converts HTML strings to object trees.The different kinds of things in an HTML document.Thrown if a failure occurs parsingtagname and attributes inside an HTML5 tagPossible tag names per the W3C HTML spec.