XML編程與應(yīng)用教程第二版上機(jī)答案.doc
《XML編程與應(yīng)用教程第二版上機(jī)答案.doc》由會(huì)員分享,可在線閱讀,更多相關(guān)《XML編程與應(yīng)用教程第二版上機(jī)答案.doc(28頁珍藏版)》請?jiān)谘b配圖網(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)品名: 描述: 價(jià)格: 現(xiàn)有量: 第六章上機(jī)題1、打開IE瀏覽器,并在地址欄中輸入U(xiǎn)RL查詢字符串: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)行實(shí)現(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ù)出版社 時(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é)點(diǎn) 4、DOMDocument 5、IXMLDOMNode選擇題:1、ABCD 2、B 3、D 4、C 5、A簡答題:1、答:最常見的節(jié)點(diǎn)類型有:(1)、元素:元素是 XML 的基本構(gòu)件。元素可以有其它元素、文本節(jié)點(diǎn)或兩者兼有來作為其子節(jié)點(diǎn)。元素節(jié)點(diǎn)還是可以有屬性的唯一類型的節(jié)點(diǎn)。 (2)、屬性:屬性節(jié)點(diǎn)包含關(guān)于元素節(jié)點(diǎn)的信息,但實(shí)際上,不認(rèn)為它是元素的子節(jié)點(diǎn)(3)、文本:文本節(jié)點(diǎn)是
17、:文本。它可以包含許多信息或僅僅是空白。 (4)、文檔(根節(jié)點(diǎn)):文檔節(jié)點(diǎn)是整個(gè)文檔中所有其它節(jié)點(diǎn)的父節(jié)點(diǎn)。 2、答:使用XML DOM,可以讓我們遍歷、讀取和操縱XML文檔的結(jié)構(gòu)和內(nèi)容,其主要對象和方法有:(1)、DOMDocument對象:描述全部文檔映射表,它包括文檔所有信息。對開發(fā)人員來說,最重要的編程對象是DOMDocument。 DOMDocument對象通過暴露的屬性和方法來允許瀏覽、查詢和修改XML文檔的內(nèi)容和結(jié)構(gòu)(2)、IXMLDOMNode對象:描述文檔里的節(jié)點(diǎn),此節(jié)點(diǎn)可以是元素、屬性、處理指令、文本或其他存儲(chǔ)在XML文檔里的信息。(3)、IXMLDOMNodeList對象
18、:描述節(jié)點(diǎn)對象的集合,可以使用該對象遍歷這個(gè)集合,可以用數(shù)值訪問。(4)、IXMLDOMParseError對象:用來驗(yàn)證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)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 川渝旅游日記成都重慶城市介紹推薦景點(diǎn)美食推薦
- XX國有企業(yè)黨委書記個(gè)人述責(zé)述廉報(bào)告及2025年重點(diǎn)工作計(jì)劃
- 世界濕地日濕地的含義及價(jià)值
- 20XX年春節(jié)節(jié)后復(fù)工安全生產(chǎn)培訓(xùn)人到場心到崗
- 大唐女子圖鑒唐朝服飾之美器物之美繪畫之美生活之美
- 節(jié)后開工第一課輕松掌握各要點(diǎn)節(jié)后常見的八大危險(xiǎn)
- 廈門城市旅游介紹廈門景點(diǎn)介紹廈門美食展示
- 節(jié)后開工第一課復(fù)工復(fù)產(chǎn)十注意節(jié)后復(fù)工十檢查
- 傳統(tǒng)文化百善孝為先孝道培訓(xùn)
- 深圳城市旅游介紹景點(diǎn)推薦美食探索
- 節(jié)后復(fù)工安全生產(chǎn)培訓(xùn)勿忘安全本心人人講安全個(gè)個(gè)會(huì)應(yīng)急
- 預(yù)防性維修管理
- 常見閥門類型及特點(diǎn)
- 設(shè)備預(yù)防性維修
- 2.乳化液泵工理論考試試題含答案