import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;import org.apache.myfaces.custom.fileupload.UploadedFile;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.XPath;
import org.dom4j.io.SAXReader;public class ReadXML {
private File xmlFile;public void readFile(String path){
try{
xmlFile=new File(path);
SAXReader reader=new SAXReader();
Document document=reader.read(xmlFile);
List list = document.selectNodes("//cc"); //这个list就是你想要的
......
......
......
}catch(Exception e){
System.out.print(e.getMessage());
}
}public static void main(String[] args) {
String path="c:/fundvalue-3.xls"; //这里换成你的文件
ReadXML OB = new ReadXML();
OB.readFile(path);
}
}
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;import org.apache.myfaces.custom.fileupload.UploadedFile;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.XPath;
import org.dom4j.io.SAXReader;public class ReadXML {
private File xmlFile;public void readFile(String path){
try{
xmlFile=new File(path);
SAXReader reader=new SAXReader();
Document document=reader.read(xmlFile);
List list = document.selectNodes("//cc"); //这个list就是你想要的
......
......
......
}catch(Exception e){
System.out.print(e.getMessage());
}
}public static void main(String[] args) {
String path="c:/fundvalue-3.xls"; //这里换成你的文件
ReadXML OB = new ReadXML();
OB.readFile(path);
}
}
import java.util.HashMap;
import org.apache.myfaces.custom.fileupload.UploadedFile;
SAXReader reader = new SAXReader();
Document doc = reader.read(f);
//得到Root节点
Element root = doc.getRootElement();
Element element;
//遍历XML树 使用枚举法
for (Iterator i = root.elementIterator("aa"); i.hasNext();) {
element = (Element) i.next();
Iterator j = element.elementIterator("bb");
Element itemElement = (Element) j.next();
Element tmp = itemElement.element("cc");
String state = tmp.getTextTrim();
.........
}