將以下XML文件的內容讀取到DOM樹中,然後分析DOM樹的結構。
<?XML version="1.0" encoding="gb2312" ?>
<!DOCTYPE company [
<!ELEMENT company (employee+)>
<!ELEMENT employee (name,age,interest*,salary,spouse?)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT interest (#PCDATA)>
<!ELEMENT salary (cash|card)>
<!ELEMENT cash (#PCDATA)>
<!ELEMENT card (#PCDATA)>
<!ELEMENT spouse (#PCDATA)>
<!ATTLIST employee id ID #REQUIRED>
<!ATTLIST employee sex (male|female) #REQUIRED>
]>
<!-- 這是根元素 -->
<company>
<employee id="_01" sex="female">
<name>張三</name>
<age>22</age>
<interest>籃球</interest>
<interest>足球</interest>
<salary>
<card>3000</card>
</salary>
</employee>
<employee id="_02" sex="male">
<name>李四</name>
<age>21</age>
<salary>
<cash>2000</cash>
</salary>
</employee>
</company>
參看下圖:
圖片看不清楚?請點擊這裡查看原圖(大圖)。