XML xml version 1 0 XML Intro xml

  • Slides: 27
Download presentation

一個XML文件範例 <? xml version = “ 1. 0” ? > XML標示 <!-- Intro. xml

一個XML文件範例 <? xml version = “ 1. 0” ? > XML標示 <!-- Intro. xml --> <!-- Simple Introduction to XML markup --> <my. Message> 註解標示 標記(元素) <message>Welcome to XML! </message> </my. Message> 資料

剖析(Parse)XML文件 � 驗證XML文件:最簡單的方式是利用IE瀏覽 器 › 請將下列兩個例子分別用IE瀏覽器打開看看 <? xml version = “ 1. 0” ?

剖析(Parse)XML文件 � 驗證XML文件:最簡單的方式是利用IE瀏覽 器 › 請將下列兩個例子分別用IE瀏覽器打開看看 <? xml version = “ 1. 0” ? > <!-- Intro. xml --> <!-- Simple Introduction to XML markup --> <my. Message> <message>Welcome to XML! </message> </my. Message> 範例 1 範例 2 <? xml version = “ 1. 0” ? > <!-- Intro. xml --> <!-- Simple Introduction to XML markup --> <my. Message> <message>Welcome to XML! </message> </my. MESSAGE>

範例 2 範例 1 所以了解XML標記的相關規範 才能寫出正確的XML文件! <? xml version = “ 1. 0” ?

範例 2 範例 1 所以了解XML標記的相關規範 才能寫出正確的XML文件! <? xml version = “ 1. 0” ? > <!-- Intro. xml --> <!-- Simple Introduction to XML markup --> <my. Message> <message>Welcome to XML! </message> </my. MESSAGE>

XML的語法 � 元素(就是標記)(Element) � 屬性(Attribute) � 處理指令(Processing Instruction) � 註解(Comment) � 文字資料 › 實體參用(Entity

XML的語法 � 元素(就是標記)(Element) � 屬性(Attribute) � 處理指令(Processing Instruction) � 註解(Comment) � 文字資料 › 實體參用(Entity Reference) › 內建實體字元(Built-in Entities) › CDATA段(CDATA Section)

正確的元素命名範例 � <Person> � <_Person> � <Home_City> � <Id-Number> � <Id. Number> � <Class

正確的元素命名範例 � <Person> � <_Person> � <Home_City> � <Id-Number> � <Id. Number> � <Class 2938> � <書籍>

錯誤的元素命名範例 � <Home City> � <. X 509> � <-Person> � <2938 Class> �

錯誤的元素命名範例 � <Home City> � <. X 509> � <-Person> � <2938 Class> � <Id#Number> � <Id^Number>

XML文件的結構 XML文件 前言(prolog) <? xml version=“ 1. 0” ? > <!-- …. . comments

XML文件的結構 XML文件 前言(prolog) <? xml version=“ 1. 0” ? > <!-- …. . comments … --> <!DOCTYPE books SYSTEM “http: //xxx. xxx/books. dtd > <!. . . Other comments and processing instruction allowed here > 主體(body) <books> <book category=“reference” > <author>XXXX</author> </book> …. </books> 結語(epilog) <!. . . Other comments and processing instruction allowed here >

XML文件的剖析 XML文件 前言(prolog) <? xml version=“ 1. 0” ? > <!-- …. . comments

XML文件的剖析 XML文件 前言(prolog) <? xml version=“ 1. 0” ? > <!-- …. . comments … --> <!DOCTYPE books SYSTEM “http: //xxx. xxx/books. dtd > <!. . . Other comments and processing instruction allowed here > 文件實體 (document entity) 前言 主體(body) <books> <book category=“reference” > <author>XXXX</author> </book> …. </books> XML 剖析器 Only one! 文件元素 (document element) 元素樹 (element tree) 結語(epilog) 結語 <!. . . Other comments and processing instruction allowed here > XML結構樹 XML文件