zoukankan      html  css  js  c++  java
  • xml解析

    使用最原始的javax.xml.parsers,标准的jdk api

    // 字符串转XML
    String xmlStr = "......";
    StringReader sr = new StringReader(xmlStr); 
    InputSource is = new InputSource(sr); 
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
    DocumentBuilder builder=factory.newDocumentBuilder(); 
    Document doc = builder.parse(is);
    NodeList list = root.getChildNodes();
    //XML转字符串 TransformerFactory tf = TransformerFactory.newInstance(); Transformer t = tf.newTransformer(); t.setOutputProperty("encoding","GB23121");//解决中文问题,试过用GBK不行 ByteArrayOutputStream bos = new ByteArrayOutputStream(); t.transform(new DOMSource(doc), new StreamResult(bos)); String xmlStr = bos.toString(); 这里的XML DOCUMENT为org.w3c.dom.Document

     

  • 相关阅读:
    API之绘图函数
    DotNetCharting
    Rule engine
    股票
    PHP
    获取Excel.dll
    Excel develop
    几个不错的开源的.net界面控件[转贴]
    关于EXCEL文件双击打不开的问题
    Regular expression
  • 原文地址:https://www.cnblogs.com/aeolian/p/7753104.html
Copyright © 2011-2022 走看看