모두 좋은 하루. 데이터베이스에 HTML 코드를 저장하려고하는데 SHEF(Swing HTML Editor Framework)을 사용하고 있지만 큰 문제가 있습니다. 일반적으로, 생성 된 HTML은 다음과 같이이다 :JSoup 또는 HTMLCleaner를 사용하여 HTML 코드를 단축하는 방법
<div>
This is the first paragraph
</div>
<div>
This is the second paragraph.
</div>
<div>
This is the last paragraph.
</div>
내가 "깨끗한"HTML 코드 및 결과이 대신처럼 보이게하려면 :
<div>
This is the first paragraph
<br>
This is the second paragraph.
<br>
This is the last paragraph.
</div>
내가 HTMLCleaner 및 JSoup을 사용하려고하지만, 나는 그것을 만들지 않았다. 난 단지 JSoup이
<div>
This is the first paragraph
</div>
<div>
</div>
<div>
This is the last paragraph.
</div>
는이되도록 작동 할 수
<div>
This is the first paragraph
</div>
<br>
<div>
This is the last paragraph.
</div>
이것은 내가 사용하는 JSoup 코드 :
Document source = Jsoup.parse(sourceString);
// For each element
for(Element el: source.select("*")) {
if(el.children().isEmpty() && !el.hasText() && el.isBlock()) {
el.replaceWith(new Element(Tag.valueOf("br"), ""));//replace empty tags with newline
}
}
return source.body().html();
짧은 생성 된 HTML 코드를 만들 수있는 방법이 있나요 ? 감사!
HTML 청소/편집은 스윙과 관련이 없습니다. 앱 때문에 스윙 태그를 추가하지 마십시오. Swing API 중 일부를 사용합니다. –