XML的作用與解析及建模(未完)

1.XML的作用:數據交換(例如網站上的天氣共享)

一前主流Xml

Webservice

現在主流Json

2.配置:

*.properties(屬性文件)   

*.xml

 

4.XML *.propertise(屬性文件)

5.Java中配置文件的三種位置即讀取方式

    5.1*.propertise(屬性文件)鍵值對儲存

    #註釋

 inputStream is = .properties文件的讀取方式(三種)

    Properties.loadis

    5.1.1src根目錄下讀取方式

    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文件")

    2.實例化一個SaxRade類

        
XML建模

         








發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章