从前台页面里传上来两个参数stopName  Date想把这两个参数传到下面的XML文件里<StopName>和 <Date>里 用java写应该怎么写写?(下面这个xml文件保存在工程的request.xml里)<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetSchTicketPlanInfoByName xmlns="http://tempuri.org/">
      <StopName>大青山</StopName>
      <Date>7月8日</Date>
    </GetSchTicketPlanInfoByName>
  </soap:Body>
</soap:Envelope>

解决方案 »

  1.   

    用JAVA自带API或JDOM   (推荐这个)
    解析读取
      

  2.   

    给你传个简单的例子:这个是从前台页面里传的key参数,/*
     * Converts a character to hex, decimal, binary, octal, and HTML, then
     * wraps each of the fields with XML and sends them back through the response.
     */
    package com.AJAXbook.servlet;import java.io.IOException;import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class AjaxResponseServlet extends HttpServlet {    public void doGet(HttpServletRequest req, HttpServletResponse res)
                throws ServletException, IOException {
            // key is the parameter passed in from the JavaScript
            // variable named url (see index.html)
            String key = req.getParameter("key");
            StringBuffer returnXML = null;
            if (key != null) {
                // extract the first character from key
                // as an int, then convert that int to a String
                int keyInt = key.charAt(0);
                returnXML = new StringBuffer("\r\n<converted-values>");
                returnXML.append("\r\n<decimal>"+
                                 Integer.toString(keyInt)+"</decimal>");
                returnXML.append("\r\n<hexadecimal>0x"+
                                 Integer.toString(keyInt,16)+"</hexadecimal>");
                returnXML.append("\r\n<octal>0"+
                                 Integer.toString(keyInt,8)+"</octal>");
                returnXML.append("\r\n<hyper>&amp;0x"+
                                 Integer.toString(keyInt,16)+";</hyper>");
                returnXML.append("\r\n<binary>"+
                                 Integer.toString(keyInt,2)+"B</binary>");
                returnXML.append("\r\n</converted-values>");            // set up the response
                res.setContentType("text/xml");
                res.setHeader("Cache-Control", "no-cache");
                // write out the XML string
                res.getWriter().write(returnXML.toString( ));
            }
            else {
                // if key comes back as a null, return a question 
                res.setContentType("text/xml");
                res.setHeader("Cache-Control", "no-cache");
                res.getWriter( ).write("?");
            }
        }
    }效果基本上是这个类型的:
    <converted-values>
        <decimal>97</decimal>
        <hexadecimal>0x61</hexadecimal>
        <octal>0141</octal>
        <hyper>&amp;0x61;</hyper>
        <binary>1100001B</binary>
    </converted-values>
      

  3.   

    我也是找了下DOM4J的文档和几个例子,多试试就好了