我最喜歡的XML(三種方式)

2022-08-27 05:42:08 字數 1711 閱讀 8896

下面的三個 xml 文件包含完全相同的資訊:

第乙個例子中使用了 date 屬性:

<

note

date

="08/08/2008">

<

to>george

to>

<

from

>john

from

>

<

heading

>reminder

heading

>

<

body

>don't forget the meeting!

body

>

note

>

第二個例子中使用了 date 元素:

<

note

>

<

date

>

08/08/2008

date>

<

to>george

to>

<

from

>john

from

>

<

heading

>reminder

heading

>

<

body

>don't forget the meeting!

body

>

note

>

第三個例子中使用了擴充套件的 date 元素(這是我的最愛):

<

note

>

<

date

>

<

day>08

day>

<

month

>08

month

>

<

year

>2008

year

>

date

>

<

to>george

to>

<

from

>john

from

>

<

heading

>reminder

heading

>

<

body

>don't forget the meeting!

body

>

note

>

因使用屬性而引起的一些問題:

請盡量使用元素來描述資料。而僅僅使用屬性來提供與資料無關的資訊。

不要做這樣的蠢事(這不是 xml 應該被使用的方式):

<

note

day="08"

month

="08"

year

="2008"

to="george"

from

="john"

heading

="reminder"

body

="don't forget the meeting!"

>

note

>

我最喜歡的對話

海姆的監牢中 乙個男人被鎖鏈鎖在監獄裡 蘭斯 塔泰亞 恩 我很驚訝你竟然還活著 我想單獨跟這個人呆一會兒 從城堡外面傳來的聲音 叛軍 接近!快去街道防守!蘭斯 塔泰亞 你聽到了嗎 贊諾比亞的聖騎士 蘭斯 漢密爾頓 你們的失敗只是時間問題而已 蘭斯 塔泰亞 我並不在乎誰統治萬萊利亞 你知道的吧 對嗎?...

linux grep 我最喜歡的命令

1 引數 i 忽略大小寫 c 列印匹配的行數 l 從多個 檔案中查詢包含匹配項 v 查詢不包含匹配項的行 n 列印包含匹配項的行和行標 2 re 正規表示式 忽略正規表示式中特殊字元的原有含義 匹配正規表示式的開始行 匹配正規表示式的結束行 從匹配正規表示式的行開始 到匹配正規表示式的行結束 單個字...

android 解析xml的三種方式

xml 可拓展的標記語言,簡單的資料儲存語言 開始標籤與結束標籤匹配 區分大小寫 標籤android 解析xml的三種方式 dom 文件物件模型 sax 事件驅動的xmlapi class 繼承org.xml.sax.helpers.defaulthandler包下的defaulthandler,重...