隨筆 - 16  文章 - 22  trackbacks - 0
          <2016年6月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

          常用鏈接

          留言簿(3)

          我參與的團隊

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          使用JAVA自帶dom包(org.w3c.dom)時,想寫入doctype
          <!DOCTYPE alert PUBLIC "SYSTEM" "TEST.dtd">




          百度不可靠,搜半天沒找到,google下就OK了

          TransformerFactory transformerFactory 
          = TransformerFactory.newInstance();
          Transformer transformer 
          = transformerFactory.newTransformer();
          transformer.setOutputProperty(OutputKeys.INDENT, 
          "yes");
          transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, 
          "no");
          transformer.setOutputProperty(OutputKeys.METHOD, 
          "xml");
          DOMImplementation domImpl 
          = document.getImplementation();
          DocumentType doctype 
          = domImpl.createDocumentType("doctype",
          "SYSTEM",
          "TEST.dtd");
          transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctype.getPublicId());
          transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctype.getSystemId());
          DOMSource source 
          = new DOMSource(document);
          StreamResult result 
          = new StreamResult(new File(database));
          transformer.transform(source, result);






          posted on 2015-07-09 11:43 rapin 閱讀(633) 評論(1)  編輯  收藏

          FeedBack:
          # re: JAVA自帶DOM包操作XML 2016-06-30 16:24 ttt
          還是google好用 百度太垃圾了   回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 拉孜县| 九江县| 延川县| 静海县| 和田市| 嘉峪关市| 进贤县| 雷州市| 呼图壁县| 翼城县| 文成县| 沭阳县| 普兰店市| 阿拉善右旗| 宁强县| 石泉县| 垫江县| 永顺县| 芜湖县| 杭锦旗| 谢通门县| 桐梓县| 宜兴市| 东乡| 沂南县| 马尔康县| 南通市| 灵山县| 高阳县| 常德市| 辽阳市| 临沂市| 白水县| 克拉玛依市| 新津县| 镇坪县| 巩留县| 同心县| 鲜城| 特克斯县| 绥中县|