myeclipse中xml解析怎么做,就是开始-新建……那些了
来源:百度知道 编辑:UC知道 时间:2024/06/08 19:02:53
package org.lovo.xml;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class TestXml{
public String gjd;
public String zjd;
public String jdname;
public String content;
public TestXml(){
File file = new File("Test.xml");
SAXBuilder builder = new SAXBuilder();
try {
Document doc = builder.build(file);
Element root = doc.getRootElement();
gjd = root.getName();
Element stu = root.getChild("student");
zjd = stu.getName();
Element name = stu.getChild("name");
jdname = name.toString();
content = name.getName();
List<Element> list = root.getChildren();
for(int i=0;i<l