XML(一)--基本概念
来源:互联网 发布:each遍历json对象二重 编辑:程序博客网 时间:2024/05/22 00:52
关于XML的完整内容可以参考:
http://www.w3schools.com/schema/default.asp
左边可以看到一个 XML Tutorial,下面包括了XML相关的所有主题。
什么是XML
XML was designed to transport and store data.
顺便提了一句,虽然大家现在看到的HTML也是XML格式的,但HTML was designed to display data.
同时HTML也不是必须是XML格式的。在早期的HTML中,一些tag是不需要有对应的closing tag的:
<p>This is a paragraph
但是现在的HTML基本上也都是XML格式的,但是这不是必须的。只有XHTML才是必须遵守XML标准的。
一个实际的例子及其简单说明
<?xml version="1.0" encoding="ISO-8859-1"?> \\XML declaration
<note date="12/11/2007"> \\ root element. root element是必须的.
<to>Tove</to> \\child element
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
1,<note>这样的标签称为一个tag,不区分level。同时XML 的tag是区分大小写的。
2,Children on the same level are called siblings (brothers or sisters).
3,tag可以有attributes。<note date="12/11/2007">中,date就是note的attribute。同时attribute的值必须用“”括起来。
4,转义:如果<to>Tove</to>这里的人名叫Gr<ace,如果直接放到XML中就会出现混乱。所以XML中定义了转义字符,对于<这类特殊字符不能直接使用,而是要改为使用:
<<less than>>greater than&&ersand ''apostrophe""quotation mark所以上例应改为<to>Gr<ace</to>5, 在XML中使用comments,使用<!--, -->将comments括起来就行了。
详细的定义
XML element
下面这个概念非常重要:
An XML element is everything from (including) the element's start tag to (including) the element's end tag.
不要将element和tag混为一谈。否在在使用c#,java等关于XML的类时的一些方法时会混乱。
XML attribute
Attributes provide additional information about an element. Attributes often provide information that is not a part of the data
<img src="computer.gif">
<file type="gif">computer.gif</file>
There are no rules about when to use attributes or when to use elements.所以下面两种写法是完全等同的:
<img src="computer.gif"> </img>
和
<img>
<src>computer.gif</src>
</img>
但是attribute虽然用起来方便,但是在扩展性,层次结构方面不如element。
- XML(一)--基本概念
- (一)Java解析XML:XML基本概念的理解
- XML基本概念
- xml基本概念
- XML基本概念
- XML基本概念
- XML基本概念解析(一) SAX、DOM、DTD和Schema
- XML基本概念解析(一) SAX、DOM、DTD和Schema
- 一,基本概念
- 一. 基本概念
- (一) 基本概念
- 【一】基本概念
- XML之XML的基本概念
- XML和XML Schema基本概念
- xml基本概念A
- xml基本概念B
- xml基本概念C
- xml基本概念D
- VS2008 automation服务器不能创建对象
- 模拟页面调度算法——1
- 降采样,过采样,欠采样,子采样,下采样
- AlarmManager的使用
- 博客第一个帖子,hello world!
- XML(一)--基本概念
- 导出wince6.0的SDK 并且添加MFC支持
- Java程序员面试
- hibernate database returned no natively generated
- WSDL
- Java模拟时钟
- 1.1.13高手谈做程序员的基本原则
- 《失恋33天》观后感
- 1.1.9中国程序员有美国梦吗