**
 * 读取xml格式的参数
 */
StringBuffer readXml = new StringBuffer();
String line = null;
boolean is = false;
try {
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null) {
readXml.append(line);
is = true;
}
} catch (Exception e) {
System.out.println(e.toString());
}
if (is) {
String xml = readXml.toString();
Document xmlDoc = null;
try {
xmlDoc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse(
new ByteArrayInputStream(xml.getBytes()));
} catch (ParserConfigurationException e) {
System.out.println("ParserConfigurationException");
} catch (SAXException e) {
System.out.println("SAXException");
} catch (Exception e) {
System.out.println(e.toString());
}
System.out.println("......已读取xml格式的参数");
/**
 * 参数1
 */
name = xmlDoc.getElementsByTagName("name").item(0).getFirstChild()
.getNodeValue();
password = xmlDoc.getElementsByTagName("password").item(0)
.getFirstChild().getNodeValue();
System.out.println("name>>>" + name + ",password>>>" + password);
}

解决方案 »

  1.   

    <<<<<<<只能用J2SE里面的方法,不用其他包,比如JDOM等,,,  >>>>>>
    不用担心jdk1.3里面都有下面的类:
    import org.w3c.dom.Document;
    import org.xml.sax.SAXException;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
      

  2.   

    按照 volcano_hosan的方法,可以了. 谢谢各位,特别是 volcano_hosan