这个问题我也问过,也解决了,看一下:http://expert.csdn.net/Expert/topic/1958/1958075.xml?temp=.4901087希望能对你有用.

解决方案 »

  1.   

    读到这个节点后<ConnectionString>。返回当前节点的firstChild就可以了。
    jdbc:mysql://localhost/abc?user=root&amp;useUnicode=true
    这个也可以看成是节点。
      

  2.   

    import javax.xml.parsers.*;
    import java.io.*;
    import org.w3c.dom.*;//获得一个xml解析器
    DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
    DocumentBuilder builder=factory.newDocumentBuilder();
    //解析XML文件
    Document document= builder.parse(new File("你的XML所在绝对路径"));
    //获取根节点
    Element root=document.getDocumentElement();
    //获取所有的"Configuration"标记,它是一个NodeList
    NodeList Configuration=root.getElementsByTagName("Configuration");
    for(int i=0;i<Configuration.getLength();i++){
          //获取Configuration的每一个元素
         Element Configurations=(Element)Configuration.item(i);
         //取ConnectionString
         String Configurations=(String)Configurations.getElementsByTagName("ConnectionString").item(0).getFirstChild().getNodeValue();
         //InternalAddr
         String InternalAddr=(String)Configurations.getElementsByTagName("InternalAddr").item(0).getFirstChild().getNodeValue();
         //取ExternalAddr
         String ExternalAddr=(String)Configurations.getElementsByTagName("ExternalAddr").item(0).getFirstChild().getNodeValue();
    }
    OK了,自己研究一下吧,累死我了
      

  3.   

    用dom4j很简单:import org.dom4j.*;
    import org.dom4j.io.*;
    import java.io.*;SAXReader r = new SAXReader();
    Document doc = r.read(new FileInputStream("parameters.xml"));connectionString = doc.selectSingleNode("Configuration/ConnectionString").getText();
    internalAddress = doc.selectSingleNode("Configuration/InternalAddress").getText();
    externalAddress = doc.selectSingleNode("Configuration/ExternalAddress").getText();