package com.apache.framework.common;import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import javax.xml.parsers.*; public class DomReadXML{
public static void main(String arge[]){ long lasting =System.currentTimeMillis();
try{
File f=new File("test.xml");
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builder=factory.newDocumentBuilder();
Document doc = builder.parse(f);
NodeList nl = doc.getElementsByTagName("f2");
System.out.println("node a is:" + doc.getElementsByTagName("a").item(0).getFirstChild().getNodeValue());
Node book=nl.item(0);
System.out.println("::"+book); }catch(Exception e){
e.printStackTrace();
}
}
}
import java.util.*;
import org.w3c.dom.*;
import javax.xml.parsers.*; public class DomReadXML{
public static void main(String arge[]){ long lasting =System.currentTimeMillis();
try{
File f=new File("test.xml");
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builder=factory.newDocumentBuilder();
Document doc = builder.parse(f);
NodeList nl = doc.getElementsByTagName("f2");
System.out.println("node a is:" + doc.getElementsByTagName("a").item(0).getFirstChild().getNodeValue());
Node book=nl.item(0);
System.out.println("::"+book); }catch(Exception e){
e.printStackTrace();
}
}
}
解决方案 »
- 虚心求解
- tomcat6.0安装版已经配置完成,输入http://localhost:80/my/index.html出现HTTP status 404错误,怎么解决?
- FormBean怎么去对应页面的多选框(select)
- 关于hibernate的缓存机制
- ajax 传值中文乱码问题...........急!!!
- java多线程
- 急寻
- 部属一个cmp的程序,在ejb-jar.xml文件中的field字段与数据库中的对应表大小写字母都是一样的,为什么却报表中不存在这些列的错
- 收购ERP源代码...(B/S)有意者请联系我
- lucene+ikanalyzer sort性能问题
- 怎么通过db.properties 文件得到DataSource
- 如果将字符串转化成日期型
例:
<x:parse doc="${xml}" var="booklist" scope="application" />
<x:set var="abook"
select="$applicationScope.booklist/
books/book[@id=$param:bookId]" />
在Java官方的J2EE Tutorial上就有相关的东东