如何用jsp读取xml文件 最好不要写java,直接jsp语句搞定,有人有办法哇? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 jdom我去学习一下。5555555 可以使用jstl标签库<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>前提是需要导入jstl的jar包! 我认为jsp和java的用法是一致的把我写的一个例子发过来希望能有点用import java.io.File;import java.util.Iterator;import org.dom4j.Element;import org.dom4j.io.SAXReader;import org.dom4j.Document;public class dom4j { public static void main(String args[]) { long start=System.currentTimeMillis(); try{ //指定xml文件 File f =new File("c:\\what.xml"); SAXReader sax = new SAXReader(); Document dc = sax.read(f); Element root = dc.getRootElement(); Element foot; for(Iterator i=root.elementIterator("first");i.hasNext();) { foot = (Element) i.next(); System.out.print("second:"+foot.elementText("second")); System.out.print("third:"+ foot.elementText("third")); } }catch(Exception e){ e.printStackTrace(); } long end = System.currentTimeMillis(); System.out.println("time="+(end-start)); }} 关于JAVAREPORT打印功能 用java技术实现对Access数据库中数据的读取的简单案例 java web 控件 JSP session失效问题 java中表格显示问题 ext.window 弹出的servlet 内的 combobox(ext)为何无法显示 想将WEB-INF\CLASSES目录下的类混淆一下,怎么做? 高手帮忙,只求一段代码?再线等,急急急...... tomcat端口被占用求解???? 十万火急!!!!一个小问题请大家帮忙 JSP错误。。。。急!!!!!!! 只求一种方案,各位有经验的来看看
我去学习一下。5555555
把我写的一个例子发过来
希望能有点用import java.io.File;
import java.util.Iterator;import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.dom4j.Document;public class dom4j {
public static void main(String args[])
{
long start=System.currentTimeMillis();
try{
//指定xml文件
File f =new File("c:\\what.xml");
SAXReader sax = new SAXReader();
Document dc = sax.read(f);
Element root = dc.getRootElement();
Element foot;
for(Iterator i=root.elementIterator("first");i.hasNext();)
{
foot = (Element) i.next();
System.out.print("second:"+foot.elementText("second"));
System.out.print("third:"+ foot.elementText("third"));
}
}catch(Exception e){
e.printStackTrace();
}
long end = System.currentTimeMillis();
System.out.println("time="+(end-start));
}
}