站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2EE 专题J2ee Tutorial学习笔记(第二章Understanding XML)

J2ee Tutorial学习笔记(第二章Understanding XML)

摘要: J2ee

J2ee Tutorial学习笔记(第二章Understanding XML)
一.Introduction to XML:
1.XML(Extensible Markup Language)是基于文本标记语言,用<>标记数据,成为Tag,但它不象HTML,XML标签确定的是数据,而不是详细的说明这个文件怎么显示,XML主要关系其中的数据.
例:
you@yourAddress.com.
me@myAddress.com
XML is Really Cool
how many ways is xml cool ?let me count the way


这个例子的Tag从整体上确定了这个message.包括其目的地址.发送地址.标题和其内容.像HTML一样...之间决定了XML的数据成分,而... tag又包涵在...中,这种一个Tag包涵另一个Tag可使XML的描述成分等级的数据结构.
2.Tag and Attributes:
tag自身也可以有其自身的Additional information.包涵在tag自身中
例: XML is Really Cool
how many ways is xml cool ?let me count the way


与上例相同,只是它把 to 和 from做进了 message 也就是作为了tag的 additional information可以简化代码,易于理解.
3.Empty Tag A1:html与XML很大的区别在与当一个xml文件很好的形成时,其附加的制约条件也是很多的,其中最重要的就是每个Tag都要有结束Tag,所以在XML中例如的结尾是必不可少的.(另外一个很重要的条件是所有的Tag都是严格嵌套的,也就是你可以.........但是不可以..........这是不允许的.
A2:有时你想建立一个空的tag你可以以 />来结尾 例如:


you@yourAddress.com.
me@myAddress.com
XML is Really Cool

how many ways is xml cool ?let me count the way


A3:XML文件注释 以

title="Sample Slide Show"
date="Date of publication"
author="Yours Truly"
>


8.完整代码: <?xml version="1.0" encoding="utf-8" ?>
-



↑返回目录
前一篇: 模式与J2EE
后一篇: Configuration,J2EE通天塔的混乱之源