【发布时间】:2013-02-10 09:55:45
【问题描述】:
我正在使用 JTidy 从 HTML 转换为 XHTML,但我在我的 XHTML 文件中找到了这个标签  。
我可以预防吗?
这是我的代码
//from html to xhtml
try
{
fis = new FileInputStream(htmlFileName);
}
catch (java.io.FileNotFoundException e)
{
System.out.println("File not found: " + htmlFileName);
}
Tidy tidy = new Tidy();
tidy.setShowWarnings(false);
tidy.setXmlTags(false);
tidy.setInputEncoding("UTF-8");
tidy.setOutputEncoding("UTF-8");
tidy.setXHTML(true);//
tidy.setMakeClean(true);
Document xmlDoc = tidy.parseDOM(fis, null);
try
{
tidy.pprint(xmlDoc,new FileOutputStream("c.xhtml"));
}
catch(Exception e)
{
}
【问题讨论】:
-
你使用的是哪个版本的 jtidy,你是怎么称呼它的?
-
@Waxolunist 谢谢我,编辑了问题,这样你就可以看到我的代码了
-
小心 .setMakeClean,因为它可能会导致和 标签合并,例如。