import java.util.*
import org.jdom.*
import org.jdom.input.*
public class MyXMLReader2JDOM {
public static void main(String arge[]) {
long lasting = System.currentTimeMillis()
try {
SAXBuilder builder = new SAXBuilder()
Document doc = builder.build(new File("xmlcount.xml"))
Element foo = doc.getRootElement()
// List allChildren = foo.getChildren()
System.out.print( foo.getAttributeValue("month-count"))
System.out.println(foo.getAttributeValue("total-count"))
} catch (Exception e) {
e.printStackTrace()
}
}
}
补充:
System.out.print(foo.getChild("date").getText())
补充:
测试通过:
import java.io.*
import java.util.*
import org.jdom.*
import org.jdom.input.*
public class MyXMLReader2JDOM {
public static void main(String arge[]) {
try {
SAXBuilder builder = new SAXBuilder()
Document doc = builder.build(new File("D:/xmlcount.xml"))
Element foo = doc.getRootElement()
System.out.println("month-count : " + foo.getAttributeValue("month-count"))
System.out.println("total-count : " + foo.getAttributeValue("total-count"))
System.out.println("date : " + foo.getChild("date").getText())
} catch (Exception e) {
e.printStackTrace()
}
}
}
jsp不可以在html上打开。只能把html代码嵌套在jsp中,且文件的扩展名是.jsp。因把jsp嵌套在html中,html文件在浏览器中,只能显示html的代码,而jsp代码只能显示原型。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)