隨筆 - 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 閱讀(628) 評論(1)  編輯  收藏

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

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


          網站導航:
           
          主站蜘蛛池模板: 丁青县| 太湖县| 衡水市| 独山县| 东丽区| 如皋市| 德惠市| 通榆县| 安吉县| 潮州市| 高邮市| 门源| 南江县| 应城市| 南康市| 天津市| 玛沁县| 东安县| 昆山市| 贡觉县| 无锡市| 英吉沙县| 资溪县| 静宁县| 山阴县| 肇源县| 梁河县| 旅游| 三明市| 谷城县| 德阳市| 满洲里市| 桂阳县| 临桂县| 社旗县| 林州市| 即墨市| 湖口县| 东港市| 新巴尔虎左旗| 潜山县|