java xml文件转换成String

解决方案 »

  1.   

    toString?呵呵你说的是解析xml吧,这个网上很多的,可以找找!DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document doc = db.parse(xmlStr);
    Document doc = stringToElement(conn.getInputStream());
    NodeList nodeList = doc.getElementsByTagName("channel");
    for (int i = 0; i < nodeList.getLength(); i++) {
    Node node = nodeList.item(i);
    NamedNodeMap nodeMap = node.getAttributes();
    Node dayNode = nodeMap.getNamedItem("day");
    dayNode.getNodeValue();//得到具体属性值
    NodeList nodeList1 = node.getChildNodes();//如果还有子节点,继续循环
    }
      

  2.   

    这个问题有比Jdom,Dom4j,sax更好的框架,simple框架实现十分简单
      

  3.   

    个人认为:Jdom 比DOM 简便