-- 作者:yuji1998
-- 发布时间:5/17/2004 1:03:00 PM
-- [0100050]我的XML學習[基础入门专题] --- 原著者:小鞋子
寫XML文件 <?xml version="1.0"?> 定義標記 <book> <title>XML</title> <author>lisongtao</author> </book> 主要是注意語法的套用 用CSS來顯示XML: 1.XML -------------------------------------------- <?xml version="1.0"?> <?xml-stylesheet type="text/css" href="1.css"?> ''連接CSS樣式表 <lisongtao> Hello the world! </lisongtao> --------------------------------------------- 1.CSS ---------------------------------------- lisongtao {display: block; font-size: 48pt; font-weight: bold;} 用XLS來顯示XML: 1.XML -------------------------------------------- <?xml version="1.0"?> <?xml-stylesheet type="text/css" href="2.xls"?> ''''連接XLS <lisongtao> Hello the world! </lisongtao> --------------------------------------------- 2.xsL ---------------------------------------- <?xml version="1.0" encoding="gb2312"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> ''定議模板開始 <xsl:template match="/"> ''根標記 <html> <head> <title>hello the world</title> </head> <body bgcolor="#CCCCFF"> <h1 align="center"><xsl:value-of select="lisongtao"/></h1>''子節點 </body> </html> </xsl:template> </xsl:stylesheet> XML 的注釋和JS一樣. <?xml version="1.0" encoding="gb2312"?> <!-- 这是一些有关书的信息 --> <books> <book> <name>xml应用</name> <author>list1</author> <price>55.00</price> </book> </books> 帶屬性的XML節點 <?xml version="1.0"?> <books title="list"> <book> <name>xml and asp</name> <price>45.00</price> <publisher>tsinghua </publisher> </book> </books> 特殊標記的用法: <?xml version="1.0"?> <books height="6'5'"> <book width="6"5""> <name>list &lisongtao</name> <author>lisongtao < list@263.net></author> </book> </books> XML中的中文標示: <?xml version="1.0" encoding="gb2312"?> <好人 > <name>小鞋子</name> </好人> DTD的使用一例 1.DTD ===================== <?xml version="1.0"?> <!ELEMENT book (price,name)> <!ELEMENT name (#PCDATA)> <!ELEMENT price (#PCDATA)> ===================== DTD.XML ================== <?xml version="1.0"?> <!DOCTYPE book SYSTEM "1.dtd"> <book> <name>lisongtao</name> <price>11.2</price> </book> 把DTD写在XML文件里面 <?xml version="1.0"?> <!DOCTYPE book [ <!ELEMENT book (price,name)> <!ELEMENT name (#PCDATA)> <!ELEMENT price (#PCDATA)> ]> <book> <price>11.2</price> <name>lisongtao</name> </book> 节点的多属性 <?xml version="1.0" encoding="gb2312"?> <books> <book name=" xml应用" author="list1" price="55.00"> </book> </books> 可缺省的结束标记的方法 <?xml version="1.0" encoding="gb2312"?> <books> <book name=" xml应用" author="list1" price="55.00"/>注意这里多了个"/" </books> CDATA文件标记的用法一例 <?xml version="1.0" encoding="gb2312"?> <books> <![CDATA[ <book> <name>xml应用</name> <author>list1</author> <price>55.00</price> </book> ]]> <book> <name>xml应用</name> <author>list1</author> <price>55.00</price> </book> </books> 经过以上的学习.总算写出一个标准的XML文件 <?xml version="1.0" encoding="gb2312"?> <!--这是一个学生选课系统的所有数据--> <choose_system> <students> <student id="984610" lesson_id="11"> <name>栗松涛</name> <age>25</age> <sex>男</sex> <department>自动化</department> </student> <student id="984611" lesson_id="12"> <name>李未</name> <age>26</age> <sex>男</sex> <department>自动化</department> </student> <student id="984612" lesson_id="11"> <name>张红</name> <age>23</age> <sex>男</sex> <department>自动化</department> </student> <student id="984613" lesson_id="12"> <name>李亮</name> <age>25</age> <sex>男</sex> <department>自动化</department> </student> </students> <lessons> <lesson id="11"> <name>控制原理</name> <num>12</num> <les_start>99.2</les_start> <les_end>99.7</les_end> <end_method>考试</end_method> </lesson> <lesson id="12"> <name>网络原理</name> <num>11</num> <les_start>99.3</les_start> <les_end>99.6</les_end> <end_method>通过</end_method> </lesson> </lessons> <teachers> <teacher id="1122" lesson_id="11"> <name>江华</name> <age>33</age> <tea_age>3</tea_age> <rank>教授</rank> <publish>控制原理</publish> <sex>男</sex> </teacher> <teacher id="1123" lesson_id="12"> <name>刘佳</name> <age>40</age> <tea_age>7</tea_age> <rank>副教授</rank> <publish>网络原理</publish> <sex>男</sex> </teacher> </teachers> </choose_system>
|