XML編程與應(yīng)用教程第二版上機(jī)答案.doc

上傳人:good****022 文檔編號:116792014 上傳時間:2022-07-06 格式:DOC 頁數(shù):28 大小:148.52KB
收藏 版權(quán)申訴 舉報 下載
XML編程與應(yīng)用教程第二版上機(jī)答案.doc_第1頁
第1頁 / 共28頁
XML編程與應(yīng)用教程第二版上機(jī)答案.doc_第2頁
第2頁 / 共28頁
XML編程與應(yīng)用教程第二版上機(jī)答案.doc_第3頁
第3頁 / 共28頁

下載文檔到電腦,查找使用更方便

10 積分

下載資源

還剩頁未讀,繼續(xù)閱讀

資源描述:

《XML編程與應(yīng)用教程第二版上機(jī)答案.doc》由會員分享,可在線閱讀,更多相關(guān)《XML編程與應(yīng)用教程第二版上機(jī)答案.doc(28頁珍藏版)》請在裝配圖網(wǎng)上搜索。

1、上機(jī)題1、 XML 指南 XML入門簡介 什么是HTML 什么是XML XML語法 XML元素必須有結(jié)束標(biāo)簽 XML元素必須正確的嵌套 2、1張三32男上海2李四22男北京3、1tom1002mary98第三章上機(jī)題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!第四章上機(jī)題1、 2、 3、 第五章上機(jī)題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)有量: 第六章上機(jī)題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、別以元素和屬性的形式進(jìn)行實現(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第七章上機(jī)題1、this is as linked element2、this is as linked element3、 機(jī)械工業(yè)出版社 這是一本C#編程語言的指南和參考書。C#是一種嶄新的面向?qū)ο蟮木幊陶Z言。它強(qiáng)調(diào)以組件為基礎(chǔ)的軟件開發(fā)方法。 湖南科學(xué)技術(shù)出版社 時間簡史以最通俗的語言,對一些最古老的問題做了闡述, 向人們介紹了什么是宇宙論,以及宇宙論最新的發(fā)展?fàn)顩r。 機(jī)械工業(yè)出版社 這是一本ASP.NET編程語言的指南和參考書。

16、 湖南科學(xué)技術(shù)出版社 這是一本Java編程語言的指南和參考書。 湖南科學(xué)技術(shù)出版社 這是一本Java ME編程語言的指南和參考書。 學(xué)習(xí)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 的基本構(gòu)件。元素可以有其它元素、文本節(jié)點或兩者兼有來作為其子節(jié)點。元素節(jié)點還是可以有屬性的唯一類型的節(jié)點。 (2)、屬性:屬性節(jié)點包含關(guān)于元素節(jié)點的信息,但實際上,不認(rèn)為它是元素的子節(jié)點(3)、文本:文本節(jié)點是

17、:文本。它可以包含許多信息或僅僅是空白。 (4)、文檔(根節(jié)點):文檔節(jié)點是整個文檔中所有其它節(jié)點的父節(jié)點。 2、答:使用XML DOM,可以讓我們遍歷、讀取和操縱XML文檔的結(jié)構(gòu)和內(nèi)容,其主要對象和方法有:(1)、DOMDocument對象:描述全部文檔映射表,它包括文檔所有信息。對開發(fā)人員來說,最重要的編程對象是DOMDocument。 DOMDocument對象通過暴露的屬性和方法來允許瀏覽、查詢和修改XML文檔的內(nèi)容和結(jié)構(gòu)(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上機(jī)題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)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!