XML編程與應用教程第二版上機答案.doc
《XML編程與應用教程第二版上機答案.doc》由會員分享,可在線閱讀,更多相關《XML編程與應用教程第二版上機答案.doc(28頁珍藏版)》請在裝配圖網(wǎng)上搜索。
1、上機題1、 XML 指南 XML入門簡介 什么是HTML 什么是XML XML語法 XML元素必須有結束標簽 XML元素必須正確的嵌套 2、1張三32男上海2李四22男北京3、1tom1002mary98第三章上機題1、 2、Environment Protection Material waste &PUBLISHER;it means the waste of substance or things from which something else can be made. For example, people throw away the used metal products an
2、d buy a new one, so the old metal waste accumulates. At last, they become waste. For example, when people finish reading newspaper, the paper will become waste. When the glass is broken, it also becomes waste. Nobody wants to use a broken window or drink with a broken glass or wear a pair of broken
3、glasses. Once it is broken, it becomes waste. The rate of using plastics is increasing day by day. People use plastic bags because they are convenient. When they get home, they throw the plastics way, paying no attention to the environment. The more convenience plastics brings to us, the more plasti
4、c waste is produced. This is called “white pollution” as most plastics are white. Some of our products we use every day are made of rubber, just like the tyres and the bottom part of our shoes. Its true that rubber plays an important role in our life. However, it also brings us some trouble when it
5、has been used for a long time and becomes old. The old tyres become waste because it cant break down by nature. This is really a big problem.Protecting the environment is not one persons duty; it depends on all of us. What can we do? Maybe a dozen. In a word, use what can reuse as much as possible.
6、Remember, environment protection is not ones duty!3、!DOCTYPE NEWSPAPER Environment Protection Material waste &PUBLISHER;it means the waste of substance or things from which something else can be made. For example, people throw away the used metal products and buy a new one, so the old metal waste ac
7、cumulates. At last, they become waste. For example, when people finish reading newspaper, the paper will become waste. When the glass is broken, it also becomes waste. Nobody wants to use a broken window or drink with a broken glass or wear a pair of broken glasses. Once it is broken, it becomes was
8、te. The rate of using plastics is increasing day by day. People use plastic bags because they are convenient. When they get home, they throw the plastics way, paying no attention to the environment. The more convenience plastics brings to us, the more plastic waste is produced. This is called “white
9、 pollution” as most plastics are white. Some of our products we use every day are made of rubber, just like the tyres and the bottom part of our shoes. Its true that rubber plays an important role in our life. However, it also brings us some trouble when it has been used for a long time and becomes
10、old. The old tyres become waste because it cant break down by nature. This is really a big problem.Protecting the environment is not one persons duty; it depends on all of us. What can we do? Maybe a dozen. In a word, use what can reuse as much as possible. Remember, environment protection is not on
11、es duty!第四章上機題1、 2、 3、 第五章上機題1、1)、 訂單信息 訂單 名稱數(shù)量城市郵編 2)、 訂單信息 訂單 名稱數(shù)量城市郵編 3)、 訂單信息 訂單 名稱數(shù)量城市郵編 2、PRODUCTNAMEfont-family:Arial;font-size:20pt;font-weight:bold;color:red;display:block;padding-top:6pt;padding-bottom:6ptPRICE,DESCRIPTION,QUANTITYfont-family:Arial;font-size:10pt;color:green;display:block;
12、padding-top:2pt;padding-bottom:2pt3、 產(chǎn)品名: 描述: 價格: 現(xiàn)有量: 第六章上機題1、打開IE瀏覽器,并在地址欄中輸入URL查詢字符串:http:/localhost/XMLTest?sql=select+*from+student+for+xml+RAW&root=roothttp:/localhost/XMLTest?sql=select+*from+ student +for+xml+Auto&root= student2、將數(shù)據(jù)“bin”、“female”、“30”以XML元素的形式插入到本章的數(shù)據(jù)庫school的student數(shù)據(jù)表中。注意,分
13、別以元素和屬性的形式進行實現(xiàn)。DECLARE doc varchar(1000)DECLARE idoc intSET doc= 5 bin female 30 exec sp_xml_preparedocument idoc output,docselect * from openxml(idoc,/ROOT/student,2)with(id int,name varchar(40),sex varchar(20), age int)insert studentselect * from openxml(idoc,/ROOT/student,2)with studentexec sp_xm
14、l_removedocument idoc3、將數(shù)據(jù)“bin”、“female”、“30”以XML屬性的形式插入到本章的數(shù)據(jù)庫school的student數(shù)據(jù)表中。USE schoolDECLARE doc varchar(1000)DECLARE idoc intSET doc= exec sp_xml_preparedocument idoc output,docselect * from openxml(idoc,/ROOT/student,1)with(id int,name varchar(40),sex varchar(20), age int)insert studentsele
15、ct * from openxml(idoc,/ROOT/student)with studentexec sp_xml_removedocument idoc第七章上機題1、this is as linked element2、this is as linked element3、 機械工業(yè)出版社 這是一本C#編程語言的指南和參考書。C#是一種嶄新的面向?qū)ο蟮木幊陶Z言。它強調(diào)以組件為基礎的軟件開發(fā)方法。 湖南科學技術出版社 時間簡史以最通俗的語言,對一些最古老的問題做了闡述, 向人們介紹了什么是宇宙論,以及宇宙論最新的發(fā)展狀況。 機械工業(yè)出版社 這是一本ASP.NET編程語言的指南和參考書。
16、 湖南科學技術出版社 這是一本Java編程語言的指南和參考書。 湖南科學技術出版社 這是一本Java ME編程語言的指南和參考書。 學習ASP.NET的書籍 第八章填空題:1、文檔對象模型 2、DOM解析器 3、節(jié)點 4、DOMDocument 5、IXMLDOMNode選擇題:1、ABCD 2、B 3、D 4、C 5、A簡答題:1、答:最常見的節(jié)點類型有:(1)、元素:元素是 XML 的基本構件。元素可以有其它元素、文本節(jié)點或兩者兼有來作為其子節(jié)點。元素節(jié)點還是可以有屬性的唯一類型的節(jié)點。 (2)、屬性:屬性節(jié)點包含關于元素節(jié)點的信息,但實際上,不認為它是元素的子節(jié)點(3)、文本:文本節(jié)點是
17、:文本。它可以包含許多信息或僅僅是空白。 (4)、文檔(根節(jié)點):文檔節(jié)點是整個文檔中所有其它節(jié)點的父節(jié)點。 2、答:使用XML DOM,可以讓我們遍歷、讀取和操縱XML文檔的結構和內(nèi)容,其主要對象和方法有:(1)、DOMDocument對象:描述全部文檔映射表,它包括文檔所有信息。對開發(fā)人員來說,最重要的編程對象是DOMDocument。 DOMDocument對象通過暴露的屬性和方法來允許瀏覽、查詢和修改XML文檔的內(nèi)容和結構(2)、IXMLDOMNode對象:描述文檔里的節(jié)點,此節(jié)點可以是元素、屬性、處理指令、文本或其他存儲在XML文檔里的信息。(3)、IXMLDOMNodeList對象
18、:描述節(jié)點對象的集合,可以使用該對象遍歷這個集合,可以用數(shù)值訪問。(4)、IXMLDOMParseError對象:用來驗證XML文檔對于DTD、XSD的正確性。第九章填空題:1、DOM SAX 2、Document 3、startDocument 4、XMLOutPutter 5、Element選擇題:1、B 2、A 3、A 4、B 5、D上機題1、(1)import javax.xml.parsers.*;import org.w3c.dom.*;public class dom public static void main(String args) try DocumentBuilder
19、Factory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder=factory.newDocumentBuilder(); Document doc=builder.parse(order.xml); NodeList nl =doc.getElementsByTagName(shipTo); for (int i=0;inl.getLength();i+) Element node=(Element) nl.item(i); System.out.print(name: ); System.out
20、.println (node.getElementsByTagName(name).item(0).getFirstChild().getNodeValue(); System.out.print(street: ); System.out.println (node.getElementsByTagName(street).item(0).getFirstChild().getNodeValue(); System.out.print(city: ); System.out.println (node.getElementsByTagName(city).item(0).getFirstCh
21、ild().getNodeValue(); System.out.print(state: ); System.out.println (node.getElementsByTagName(state).item(0).getFirstChild().getNodeValue(); System.out.print(zip: ); System.out.println (node.getElementsByTagName(zip).item(0).getFirstChild().getNodeValue(); System.out.println(); NodeList n2 =doc.get
22、ElementsByTagName(billTo); for (int i=0;in2.getLength();i+) Element node=(Element) n2.item(i); System.out.print(name: ); System.out.println (node.getElementsByTagName(name).item(0).getFirstChild().getNodeValue(); System.out.print(street: ); System.out.println (node.getElementsByTagName(street).item(
23、0).getFirstChild().getNodeValue(); System.out.print(city: ); System.out.println (node.getElementsByTagName(city).item(0).getFirstChild().getNodeValue(); System.out.print(state: ); System.out.println (node.getElementsByTagName(state).item(0).getFirstChild().getNodeValue(); System.out.print(zip: ); Sy
24、stem.out.println (node.getElementsByTagName(zip).item(0).getFirstChild().getNodeValue(); System.out.println(); NodeList n3 =doc.getElementsByTagName(item); for (int i=0;in3.getLength();i+) Element node=(Element) n3.item(i); System.out.print(productName: ); System.out.println (node.getElementsByTagNa
25、me(productName).item(0).getFirstChild().getNodeValue(); System.out.print(quantity: ); System.out.println (node.getElementsByTagName(quantity).item(0).getFirstChild().getNodeValue(); System.out.print(USPrice: ); System.out.println (node.getElementsByTagName(USPrice).item(0).getFirstChild().getNodeVal
26、ue(); System.out.print(comment: ); System.out.println (node.getElementsByTagName(comment).item(0).getFirstChild().getNodeValue(); System.out.println(); catch(Exception e) e.printStackTrace(); (2)import javax.xml.parsers.*;import org.w3c.dom.*;import java.io.*;import org.apache.crimson.tree.*;public
27、class InsertElement public static void main(String args) Element items=null; Element item=null; Element productName = null; Element quantity = null; Element USPrice = null; Element shipDate = null; try DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder=fac
28、tory.newDocumentBuilder(); Document doc=builder.parse(order.xml); NodeList nl =doc.getElementsByTagName(items); items=(Element)nl.item(0); item = doc.createElement(item); item.setAttribute(partNum, 926-AA); productName = doc.createElement(productName); productName.appendChild(doc.createTextNode(Baby
29、 Monitor); item.appendChild(productName);quantity = doc.createElement(quantity);quantity.appendChild(doc.createTextNode(1);item.appendChild(quantity);USPrice = doc.createElement(USPrice);USPrice.appendChild(doc.createTextNode(39.98);item.appendChild(USPrice);shipDate = doc.createElement(shipDate);sh
30、ipDate.appendChild(doc.createTextNode(1999-05-21);item.appendChild(shipDate); items.appendChild(item); (XmlDocument)doc).write(new FileOutputStream(test1.xml); catch(Exception e) e.printStackTrace(); 2、import java.io.IOException;import javax.xml.parsers.*;import org.xml.sax.Attributes;import org.xml.sax.SAXException;import org.xml.sax.helpers.DefaultHandler;pu
- 溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 指向核心素養(yǎng)發(fā)展的高中生物學1輪復習備考建議
- 新課程新評價新高考導向下高三化學備考的新思考
- 新時代背景下化學高考備考策略及新課程標準的高中化學教學思考
- 2025屆江西省高考政治二輪復習備考建議
- 新教材新高考背景下的化學科學備考策略
- 新高考背景下的2024年高考化學二輪復習備考策略
- 2025屆高三數(shù)學二輪復習備考交流會課件
- 2025年高考化學復習研究與展望
- 2024年高考化學復習備考講座
- 2025屆高考數(shù)學二輪復習備考策略和方向
- 2024年感動中國十大人物事跡及頒獎詞
- XX教育系統(tǒng)單位述職報告教育工作概述教育成果展示面臨的挑戰(zhàn)未來規(guī)劃
- 2025《增值稅法》全文解讀學習高質(zhì)量發(fā)展的增值稅制度規(guī)范增值稅的征收和繳納
- 初中資料:400個語文優(yōu)秀作文標題
- 初中語文考試專項練習題(含答案)