没有有过,不过你把Html变成xml意欲何为呢?
生成的xml的schema是什么样的?

解决方案 »

  1.   

    就是想把HTML转化成DOM树的形式, 便于抽取里面的信息了
    一般的HTML不都是不太规范的吗, 就是想用JTidy调整这些不规范的东西,
      

  2.   

    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();
    }
    }

    }
      

  3.   

    td.setCharEncoding(Configuration.RAW);
    设置一下