或者是java的xml数据绑定,都有这方面的内容。再不行就啃一下apache的soap源码。
地址:http://xml.apache.org/

解决方案 »

  1.   

    import java.io.InputStream;
    import java.text.SimpleDateFormat;
    import java.util.Date;import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;import org.w3c.dom.Node;
    import org.w3c.dom.Document;/**
     * A factory used to craete Stock objects, in this case from an XML document.
     *
     * @author    Simon Brown
     */
    public class StockFactory {  /** the singleton instance */
      private static final StockFactory instance = new StockFactory();  /**
       * Private constructor for the singleton pattern.
       */
      private StockFactory() {
      }  /**
       * Gets the singleton instance.
       *
       * @return  the singleton StockFactory instance
       */
      public static StockFactory getInstance() {
        return instance;
      }  /**
       * Parses the XML document provided by the InputStream into a Stock instance.
       *
       * @param in    the InputStream from which to read the document
       * @return  a Stock instance
       * @throws  Exception   should anything go wrong in parsing the document
       */
      public Stock getStock(InputStream in) throws StockException {    Stock stock;    try {
          // create a factory and builder - an abstraction for an XML parser
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          DocumentBuilder builder = factory.newDocumentBuilder();      // get a reference to the document
          Document doc = builder.parse(in);
          Node root = doc.getDocumentElement();
          Node node;      String symbol;
          float price;
          float change;
          Date date;      // and now traverse the document for the required information
          // (not forgetting to skip over whitespace in the document)
          node = root.getFirstChild();
          node = node.getNextSibling();
          symbol = node.getFirstChild().getNodeValue();      node = node.getNextSibling();
          node = node.getNextSibling();
          price = Float.parseFloat(node.getFirstChild().getNodeValue());      node = node.getNextSibling();
          node = node.getNextSibling();
          change = Float.parseFloat(node.getFirstChild().getNodeValue());      SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
          node = node.getNextSibling();
          node = node.getNextSibling();
          date = sdf.parse(node.getFirstChild().getNodeValue());      return new Stock(symbol, price, change, date);
        } catch (Exception e) {
          throw new StockException("Could not parse stock from XML document.");
        }
      }}
    用xml解析器, URL url = new URL(url);
    InputStream in = url.openStream();
    将得到的in放入以上的代码!
      

  2.   

    我就是想知道如何用java从http里得到数据包,又如何发送数据包
      

  3.   

    没有搞错吧?java.net.URLConnection类有个getOutputStream() 的方法啊!
    不行就用apache soap里面提供一些http的类库,那个比较高级一点。
      

  4.   

    OutputStream.write()写就可以了啊!
      

  5.   

    看看HTTP协议就懂了,什么接收发送不就是读写字节么,有什么很高深的吗