隨筆 - 16  文章 - 22  trackbacks - 0
          <2015年7月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          常用鏈接

          留言簿(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 閱讀(627) 評論(1)  編輯  收藏

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

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 宁夏| 即墨市| 淳化县| 芜湖县| 轮台县| 福建省| 贵州省| 临沧市| 新乡市| 高平市| 任丘市| 高尔夫| 怀柔区| 黄大仙区| 乐至县| 翁源县| 临汾市| 涟源市| 静海县| 常德市| 凤翔县| 永嘉县| 神池县| 湛江市| 共和县| 井陉县| 文水县| 江都市| 光泽县| 开江县| 古蔺县| 拉孜县| 察隅县| 新营市| 汉沽区| 阿瓦提县| 精河县| 项城市| 黎川县| 麻城市| 曲阳县|