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()));
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()));
解决方案 »
- 利用离散点求积分
- spring依赖注入问题
- struts2中在地址后传递参数的问题
- 一道面试题
- struts context-path的问题
- 求数据处理层 屏蔽分层(变化) 详解~!
- 网页上有一个applet和一个文本框(不在applet上,属于网页的).点applet上的一个按钮,让applet得到文本框里的值,请问,谁有这样的代码?
- 组件“struts-config”在此不允许“message-resources”。这个算什么错误,错误在哪里呢??
- 初学JB8遇到问题,请指教!
- 请问谁有开发基于J2EE的电子商务方面的经验
- 如何在JAVA程序中调用ASP页面得到XML结果?
- 请问几个JAVA术语是什么意思,比如J2EE,WEBSPHERE,WEBLOGIC,TOMCAT
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()));
请问你是怎么使applet支持xerces的
符号:类 InputSource
位置:类 in DBTable
parser.parse(new InputSource(new URL(xmlFile).openStream()));
^
1 个错误leolee(历历)请教一下
InputSource在那个包啊 ?
另外我要把一个db的table通过xml抓回来,大约100-300条纪录。我用标准DOM解析好呢,还是用JDOM解析好?
org.apache.xerces
org.w3c.dom
org.xml.sax
全都打进去了吗,是不是太大了,试没试过用plug-in。
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一块打包就行了。
太感谢你了,我试一试
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--这一回事么?
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里有东西的话。
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;
}
}
DataInputStream din=new DataInputStream(url.openStream());
InputSource in=new InputSource(din);
parser.parse(in);
//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;
}
}
用上面这种方法把几千到一万条纪录的xml传到客户端的IE上,效果怎么样?动作灵活么?传输的时间有多长?