JavaWeb學習筆記 XML 2

2021-08-10 08:42:39 字數 747 閱讀 5131

dtd約束

對xml檔案進行驗證

1、事例

book.xml

<?xml version="1.0" encoding="utf-8"?>

《書架》

《書》《書名》

書名》《作者》

作者》《售價》

售價》書》

書架》

book.dtd

2、引用

dtd可以在xml檔案內部或寫在.dtd檔案內

引用本地檔案

引用公共檔案

3、語法細節

a、元素定義

b、元素內容

myfile (title,author,email)>

myfile (title|author|email)>

myfile ((title*,author?,email)*|comment)>

3、屬性定義attlist

屬性名1 屬性值型別 設定說明

屬性名2 屬性值型別 設定說明

>

programmer">

學習訪問XML2 寫入XML資料

讀取乙個doc setattribute方法設定屬性 removechild方法刪除乙個子節點 組合用來建立節點 domsource domsource new domsource doc transforme ctory transfactory transforme ctory.newinsta...

XML 2 筆記分享

解析xml 生成dom物件 saxreader reader newsaxreader document document reader.read resources books.xml 獲得根節點 element rootele document.getrootelement 獲得根節點下所有bo...

JavaWeb學習筆記 XML 6

獲取第二本書的書名與屬性 public void read string attribute book.element 書名 attributevalue name 在第一本書上新增新售價 本例存在編碼問題 public void add throws exception book.addeleme...