jsoup icon indicating copy to clipboard operation
jsoup copied to clipboard

Missing the end tag

Open WayneLee5991 opened this issue 5 years ago • 4 comments

Document parse = Jsoup.parse("<img th:src="" width="50" height="50" alt="fail" />"); String result = parse.html(); I need <img th:src="" width="50" height="50" alt="fail" />
but I get <img th:src="" width="50" height="50" alt="fail" >
where did the '/' go? and how can I get '/'?

WayneLee5991 avatar Dec 28 '20 09:12 WayneLee5991

jsoup defaults to HTML5, where self-closing tags aren't a thing. If you want XML, you can use the XML parser. See e.g. https://try.jsoup.org/~Qgdx_A13CctCvLA1C4WZRNhpJ-c

Also, best to use StackOverflow for Q&A; we use GitHub Issues for issue tracking.

jhy avatar Dec 28 '20 12:12 jhy

jsoup defaults to HTML5, where self-closing tags aren't a thing. If you want XML, you can use the XML parser. See e.g. https://try.jsoup.org/~Qgdx_A13CctCvLA1C4WZRNhpJ-c

Also, best to use StackOverflow for Q&A; we use GitHub Issues for issue tracking.

sorry about that,I can’t open StackOverflow,because google is forbidden for me,and I can‘t find a anwser from the other search engines. fortunately,I found a solution

org.jsoup.nodes.Document document = Jsoup.parse(originalHtmlTemplate);
document.outputSettings().syntax(org.jsoup.nodes.Document.OutputSettings.Syntax.xml);
document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);

thanks a lot

WayneLee5991 avatar Dec 29 '20 04:12 WayneLee5991

@WayneLee5991 sorry, I hadn't considered that Google or StackOverflow may be blocked or partially accessible. Glad you found the fix. I'll have a think about copying the common StackOverflow jsoup FAQs over to the jsoup.org documentation site. Do you think that would be useful?

jhy avatar Dec 29 '20 06:12 jhy

@WayneLee5991 sorry, I hadn't considered that Google or StackOverflow may be blocked or partially accessible. Glad you found the fix. I'll have a think about copying the common StackOverflow jsoup FAQs over to the jsoup.org documentation site. Do you think that would be useful? It could‘t be better,you also can put some FAQs in the README.

WayneLee5991 avatar Dec 29 '20 06:12 WayneLee5991