发表于: 2016-08-19 00:04:46
3 2381
http://tomcat.apache.org/download-90.cgi下载并配置Apache Tomcat 9.0包eclipse创建DynamicWebProject,加载apache tomcat9.0在build path-libraries-add external jars-servlet-api.jar 创建找不到index.jsp,在师兄建议下,IDE更换为idea
************************************************************************
XML基础知识
1.宗旨存储、传输数据
2.树结构<bookstore> <book category="COOKING"> <title>Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB"> <title>Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore>
3.实体引用在 XML 中,有 5 个预定义的实体引用:
< | < | 小于 |
> | > | 大于 |
& | & | 和号 |
' | ' | 单引号 |
" | " | 引号 |
4.注释<!-- This is a comment -->
5.命名规则
- 名称可以含字母、数字以及其他的字符
- 名称不能以数字或者标点符号开始
- 名称不能以字符 “xml”(或者 XML、Xml)开始
- 名称不能包含空格
可使用任何名称,没有保留的字词。
6.元素属性属性值必须加引号<file type="gif">computer.gif</file><person sex='female'>有多层引号<gangster name='George "Shotgun" Ziegler'><gangster name="George "Shotgun" Ziegler">HTML中属性便利,但XML中尽量把属性转化为子元素<note> <date> <day>08</day> <month>08</month> <year>2008</year> </date> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
7.XML解析器解析xml文档示例<html><body><h1>W3School.com.cn Internal Note</h1><p><b>To:</b> <span id="to"></span><br /><b>From:</b> <span id="from"></span><br /><b>Message:</b> <span id="message"></span></p><script>txt="<bookstore><book>"; txt=txt+"<title>Everyday Italian</title>"; txt=txt+"<author>Giada De Laurentiis</author>"; txt=txt+"<year>2005</year>"; txt=txt+"</book></bookstore>"; if (window.DOMParser) { parser=new DOMParser(); xmlDoc=parser.parseFromString(txt,"text/xml"); } else // Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(txt); }</script></body></html>
8.DOMXML DOM示例xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue
- xmlDoc -由解析器创建的 XML 文档
- getElementsByTagName("to")[0] - 第一个 <to> 元素
- childNodes[0] - <to> 元素的第一个子元素(文本节点)
- nodeValue - 节点的值(文本本身)
HTML DOM示例document.getElementById("to").innerHTML=
- document - HTML 文档
- getElementById("to") - 其中的 id="to" 的 HTML 元素
- innerHTML - HTML 元素的内部文本
评论