DOMParser parser = new DOMParser("http://111.112.3.12:7001/pooltest4?kind=test");
parser.parse(xmlFile);一、DOMParser没有此构造函数吧???
二、xmlFile从哪来的?偶没看到。
只有parser.parse(InputSource source);
    parser.parse(String srcFile);
两种签名,你用错了!
正确的我觉得应该是:
DOMParser parser=new DOMParser();
parser.parse(new InputSource(new URL("http://111.112.3.12:7001/pooltest4?kind=test").openStream()));
        

解决方案 »

  1.   

    再接:假如你的开销不太大,不一定用标准DOM解析,毕竟太低层,非常的累,使用JDOM包做会轻松很多,它对SAX进行了更高的封装,但开销要大点,可以直接支持URL这类的连接,很方便。
      

  2.   

    贴错了!高手!是这样的。
    string xmlFile="http://111.112.3.12:7001/pooltest4?kind=test";
    DOMParser parser = new DOMParser();
    parser.parse(xmlFile);我是试一下下面的去!谢谢
    parser.parse(new InputSource(new URL("http://111.112.3.12:7001/pooltest4?kind=test").openStream()));
      

  3.   

    jean777(jean777):
    请问你是怎么使applet支持xerces的
      

  4.   

    DBTable.java:271: 不能解析符号
    符号:类 InputSource
    位置:类 in DBTable
             parser.parse(new InputSource(new URL(xmlFile).openStream()));
                              ^
    1 个错误leolee(历历)请教一下 
    InputSource在那个包啊 ?
    另外我要把一个db的table通过xml抓回来,大约100-300条纪录。我用标准DOM解析好呢,还是用JDOM解析好?
      

  5.   

    jean777(jean777):
    org.apache.xerces
    org.w3c.dom
    org.xml.sax
    全都打进去了吗,是不是太大了,试没试过用plug-in。
      

  6.   

    这么点数据量用JDOM足够了,在我的报表里通常是几千到一万的,需要DOM解析。
    InputSource是在org.xml.sax.InputSource,是Xerces的。
    public void parse(InputSource source) throws SAXException,java.io.IOException
    public void parse(java.lang.String systemId)throws SAXException,java.io.IOException我的意思是将servlet out出来的XML文件数据流构造成InputSource,这样才可以parse。
    可以考虑将servlet输出的XML文件做成一个ByteArrayOutputStream然后对象序列化传输到Applet接收。然后对这个字节流构造InputSource。BTW to blackfox_jl:将Xerces一块打包就行了。
      

  7.   

    不需要全打进去吧,使用JB中的Archive builder,可以只打入用到的类。小了非常很多。
      

  8.   

    leolee(历历):
    太感谢你了,我试一试
      

  9.   

    可以考虑将servlet输出的XML文件做成一个ByteArrayOutputStream然后对象序列化传输到Applet接收。然后对这个字节流构造InputSource。我也想这样做,
    String queryString = "/receiveservlet?message="+URLEncoder.encode(message);
    String chatURL ="http://111.112.3.12:7001";
    int oldCount, index, blockCount;
    connect = (new URL(chatURL+queryString)).openConnection();
    showStatus("open connection!");
    //下次连接不用Cache
    connect.setDefaultUseCaches(false);
    //这次连接也不用Cache
    connect.setUseCaches(false);
    //打开淂流用于读数据
    connect.setDoInput(true);
    //不能用于写数据
    connect.setDoOutput(false);
    //服务器与客户的真正连接
    connect.connect();
    showStatus("Open Stream!");
    DataInputStream in = new DataInputStream(connect.getInputStream());
    showStatus("reading!");
    message = message +in.readLine();
    然后再对这个字节流构造InputSource就不会了!!!leolee(历历) 帮我啊plug_in?我准备让客户端装jre1.3--这一回事么?
      

  10.   

    看看InputSource的构造函数。
    InputSource() 
              Zero-argument default constructor. 
    InputSource(java.io.InputStream byteStream) 
              Create a new input source with a byte stream. 
    InputSource(java.io.Reader characterStream) 
              Create a new input source with a character stream. 
    InputSource(java.lang.String systemId) 
              Create a new input source with a system identifier. 所以 new InputSource(in);//如果in里有东西的话。
      

  11.   

    document还是为null!!!leolee(历历) 帮我啊,我要崩溃了String xmlFile="http://111.112.3.12:7001/pooltest4?kind=test";
    public Document getxml(String xmlFile) {

          //System.out.print("asdasfSDF");
          //  Create a Xerces DOM Parser
          DOMParser parser = new DOMParser();
    try {
             parser.parse(new InputSource(new URL(xmlFile).openStream()));
             Document document = parser.getDocument();
            //System.out.print("get xml");
          return document;
          } catch (Exception e) {
             System.err.println (e);
             return null;
             
          }
          
    }  
      

  12.   

    吃过饭通过程序,看吧URL url=new URL("http://localhost:8080/servlet/Test");
    DataInputStream din=new DataInputStream(url.openStream());
    InputSource in=new InputSource(din);
    parser.parse(in);
      

  13.   

    我的程序也通过了,多谢leolee(历历)的帮助,这是对这个字节流构造InputSource的方法我终于会了。分不多,都给你了public Document getxml(String xmlFile) {

          //System.out.print("asdasfSDF");
          //  Create a Xerces DOM Parser
     
          DOMParser parser = new DOMParser();
    String attributeName;
          //  Parse the Document     
          //  and traverse the DOM
          try {
            URLConnection connect = (new URL(xmlFile)).openConnection();
    //下次连接不用Cache
    connect.setDefaultUseCaches(false);
    //这次连接也不用Cache
    connect.setUseCaches(false);
    //打开淂流用于读数据
    connect.setDoInput(true);
    //不能用于写数据
    connect.setDoOutput(false);
    //服务器与客户的真正连接
    connect.connect();            
             parser.parse(new InputSource(connect.getInputStream()));
             Document document = parser.getDocument();
            //System.out.print("get xml");
          return document;
          } catch (Exception e) {
             System.err.println (e);
             return null;
             
          }
          
    }  
      

  14.   

    可以考虑将servlet输出的XML文件做成一个ByteArrayOutputStream然后对象序列化传输到Applet接收。然后对这个字节流构造InputSource。
    用上面这种方法把几千到一万条纪录的xml传到客户端的IE上,效果怎么样?动作灵活么?传输的时间有多长?
      

  15.   

    你的email给我一个吧!,以后还要向你多学习呢!