在Java中html到xhtml的转换 [英] html to xhtml conversion in java

查看:43
本文介绍了在Java中html到xhtml的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何使用Http类api将html转换为格式正确的xhtml,请尽可能给出一个演示代码....谢谢

how can we convert html to well formed xhtml by using Http class api,if possible please give a demonstration code....thanks

推荐答案

如果适合您,我只是使用Jsoup做到了:

I just did it using Jsoup, if it works for you:

private String htmlToXhtml(final String html) {
    final Document document = Jsoup.parse(html);
    document.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
    return document.html();
}

我的解决方案来自一些有用的内容:

Some useful content where my solution came from:

这篇关于在Java中html到xhtml的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆