哪位使用过JTidy的,我将html转换成xml时总会碰到中文变成乱码的问题 没有有过,不过你把Html变成xml意欲何为呢?生成的xml的schema是什么样的? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是想把HTML转化成DOM树的形式, 便于抽取里面的信息了一般的HTML不都是不太规范的吗, 就是想用JTidy调整这些不规范的东西, public class HtmlToXml { private FileOutputStream fout = null; public HtmlToXml(FileInputStream in ,String outFilename) throws Exception{ try{ Tidy td = new Tidy(); fout = new FileOutputStream(outFilename);//outFilename="c:\\abc.txt" //out = new BufferedOutputStream(fout); td.setCharEncoding(Configuration.RAW); //td.setEmacs(true); //td.setRawOut(true); td.setIndentContent(true); //这个函数使过滤后的文本不会在其前加空格 td.setBreakBeforeBR(true); td.setShowWarnings(false); td.setWraplen(0); //设置文本的长度,0为没有限制 td.setXmlOut(true); td.parseDOM(in,fout); }catch(Exception e){ e.printStackTrace(); }finally{ if(fout!=null) fout.close(); } } } td.setCharEncoding(Configuration.RAW);设置一下 tomcat 发布war文件 无法运行 java webservices用的多吗? 明天要面试了,问大家2个问题。 麻烦给个好的分页方法 为什么我安装Tomcat的时候会中止呢? 高手帮我看看如何在延迟加载中使用OpenSessionInViewInterceptor MySql的驱动包谁有发我个啊 感激不尽 word转化的XML文件中 的图片是用什么编码编的 要读取出来怎么弄? 大虾速入!!!!!!!! 来来来!具弱智的问题! 关于邮箱验证修改密码的问题 各位高手,谁能给我解释一下这段代码? Spring问题:把界面控件用Spring 的bean configuration 这样做合理吗?
一般的HTML不都是不太规范的吗, 就是想用JTidy调整这些不规范的东西,
public HtmlToXml(FileInputStream in ,String outFilename) throws Exception{
try{
Tidy td = new Tidy(); fout = new FileOutputStream(outFilename);//outFilename="c:\\abc.txt"
//out = new BufferedOutputStream(fout);
td.setCharEncoding(Configuration.RAW);
//td.setEmacs(true);
//td.setRawOut(true);
td.setIndentContent(true); //这个函数使过滤后的文本不会在其前加空格
td.setBreakBeforeBR(true); td.setShowWarnings(false);
td.setWraplen(0); //设置文本的长度,0为没有限制
td.setXmlOut(true);
td.parseDOM(in,fout);
}catch(Exception e){
e.printStackTrace();
}finally{
if(fout!=null)
fout.close();
}
}
}
设置一下