Java HTML 파서 라이브러리에서 닫기 태그 (예 : </h1>
)를 처리하려면 어떻게해야합니까? 예를 들어Java Html 파서 및 닫기 태그
, 나는 다음과 같은 경우 :
public class MyFilter implements NodeFilter {
public boolean accept(Node node) {
if (node instanceof TagNode) {
TagNode theNode = (TagNode) node;
if (theNode.getRawTagName().equals("h1")) {
return true;
} else {
return false;
}
}
return false;
}
}
public class MyParser {
public final String parseString(String input) {
Parser parser = new Parser();
MyFilter theFilter = new MyFilter();
parser.setInputHTML("<h1>Welcome, User</h1>");
NodeList theList = parser.parse(theFilter);
return theList.toHtml();
}
}
내 파서를 실행하면, 내가 다시 다음과 같은 출력 얻을 :
<h1>Welcome, User</h1>Welcome, User</h1>
노드 목록이 규모 3의 목록이 포함되어 있습니다 다음 엔터티 :
(tagNode) <h1>
(textNode) Welcome, User
(tagNode) </h1>
출력을 "<h1>Welcome, User</h1>
"으로하고 싶습니다. 누구나 내 샘플 파서에서 무엇이 잘못되었는지 보시겠습니까?