XML编程与应用教程第二版上机答案.doc

上传人:s****u 文档编号:12749678 上传时间:2020-05-22 格式:DOC 页数:28 大小:148.52KB
返回 下载 相关 举报
XML编程与应用教程第二版上机答案.doc_第1页
第1页 / 共28页
XML编程与应用教程第二版上机答案.doc_第2页
第2页 / 共28页
XML编程与应用教程第二版上机答案.doc_第3页
第3页 / 共28页
点击查看更多>>
资源描述
上机题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 and 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 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 plastic 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 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. 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 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 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 plastic 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 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. Remember, environment protection is not ones duty!第四章上机题1、 2、 3、 第五章上机题1、1)、 订单信息 订单 名称数量城市邮编 2)、 订单信息 订单 名称数量城市邮编 3)、 订单信息 订单 名称数量城市邮编 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;padding-top:2pt;padding-bottom:2pt3、 产品名: 描述: 价格: 现有量: 第六章上机题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、将数据“bin”、“female”、“30”以XML元素的形式插入到本章的数据库school的student数据表中。注意,分别以元素和属性的形式进行实现。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_xml_removedocument idoc3、将数据“bin”、“female”、“30”以XML属性的形式插入到本章的数据库school的student数据表中。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 studentselect * from openxml(idoc,/ROOT/student)with studentexec sp_xml_removedocument idoc第七章上机题1、this is as linked element2、this is as linked element3、 机械工业出版社 这是一本C#编程语言的指南和参考书。C#是一种崭新的面向对象的编程语言。它强调以组件为基础的软件开发方法。 湖南科学技术出版社 时间简史以最通俗的语言,对一些最古老的问题做了阐述, 向人们介绍了什么是宇宙论,以及宇宙论最新的发展状况。 机械工业出版社 这是一本ASP.NET编程语言的指南和参考书。 湖南科学技术出版社 这是一本Java编程语言的指南和参考书。 湖南科学技术出版社 这是一本Java ME编程语言的指南和参考书。 学习ASP.NET的书籍 第八章填空题:1、文档对象模型 2、DOM解析器 3、节点 4、DOMDocument 5、IXMLDOMNode选择题:1、ABCD 2、B 3、D 4、C 5、A简答题:1、答:最常见的节点类型有:(1)、元素:元素是 XML 的基本构件。元素可以有其它元素、文本节点或两者兼有来作为其子节点。元素节点还是可以有属性的唯一类型的节点。 (2)、属性:属性节点包含关于元素节点的信息,但实际上,不认为它是元素的子节点(3)、文本:文本节点是:文本。它可以包含许多信息或仅仅是空白。 (4)、文档(根节点):文档节点是整个文档中所有其它节点的父节点。 2、答:使用XML DOM,可以让我们遍历、读取和操纵XML文档的结构和内容,其主要对象和方法有:(1)、DOMDocument对象:描述全部文档映射表,它包括文档所有信息。对开发人员来说,最重要的编程对象是DOMDocument。 DOMDocument对象通过暴露的属性和方法来允许浏览、查询和修改XML文档的内容和结构(2)、IXMLDOMNode对象:描述文档里的节点,此节点可以是元素、属性、处理指令、文本或其他存储在XML文档里的信息。(3)、IXMLDOMNodeList对象:描述节点对象的集合,可以使用该对象遍历这个集合,可以用数值访问。(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 DocumentBuilderFactory 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.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).getFirstChild().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.getElementsByTagName(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(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: ); System.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.getElementsByTagName(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().getNodeValue(); 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 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=factory.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 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);shipDate.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
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 考试试卷


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!