FragranceM 发表于 2015-10-5 13:20:35

IBM网站上给出的XML的介绍(3)不完全摘录




End tags are required(tag的“完整性”)
Page 5 of 10


  You can't leave out any end tags. In the first example below, the markup is not legal because there are no end paragraph (</p>) tags. While this is acceptable in HTML (and, in some cases, SGML), an XML parser will reject it.


<!-- NOT legal XML markup -->
<p>Yada yada yada...
<p>Yada yada yada...
<p>...

  If an element contains no markup at all it is called an empty element; the HTML break (<br>) and image (<img>) elements are two examples. In empty elements in XML documents, you can put the closing slash in the start tag. The two break elements and the two image elements below mean the same thing to an XML parser:


<!-- Two equivalent break elements -->
<br></br>
<br />
<!-- Two equivalent image elements -->
<img src="../img/c.gif"></img>
<img src="../img/c.gif" />




当然,这里不仅指tag,同时也适用于elment和attribute
页: [1]
查看完整版本: IBM网站上给出的XML的介绍(3)不完全摘录