1.XML的作用:数据交换(例如网站上的天气共享)
一前主流Xml
Webservice
现在主流Json
2.配置:
*.properties(属性文件)
*.xml
4.XML 和*.propertise(属性文件)
5.Java中配置文件的三种位置即读取方式
5.1*.propertise(属性文件)键值对储存
#注释
inputStream is = .properties文件的读取方式(三种)
Properties.load(is)
5.1.1在src根目录下读取方式
Xxx.class.getResourceAsStream(/xx.properties)
5.1.2在同一个包读取方式
Xxx.class.getResourceAsStream(xx.properties)
5.1.3放在WEB-INF(或其子目录)读取方式
ServletContext application = this.getServletContext();
InputStream is = application.getResourceAsStream(“/web-inf/xx.properties”);
6. Dom4j+xpath解析XML文件
DOM由节点组成
Node
元素节点
属性节点
文本节点
查询方法(xpath等同数据库的select语句)
document.selectNodes(xpath);//查一组
document.selectSingleNode(xpath);//查单个
xpath
/ 路径 在系统中建一个文件叫document/students/student/sid|name
@ 属性
students.xml
解析xml文件步骤(使用Dom4J与Xpath)
1.创建流,在流中获得xml文件的资源
inputStream is = Xxx(类).class.getResourcesAsStream("*.xml文件")