XML Syntax
- CDATA
<![CDATA[
if ( a > b ) {
printf("in if : a > b\n");
} else {
printf("in else : a <= b\n");
}
]]>
- Comment
<!-- Single Comment Line -->
<!--
Multiple Coment Part :
line#1
line#2
line#3
-->
- DOCTYPE
Single Layer
<!DOCTYPE note [
<!ENTITY CompanyName 'Liquid Technologies Ltd'>
]>
Multiple Layers
<!DOCTYPE note [
<!ELEMENT body1 (#PCDATA)>
[ innerContent1
<!ELEMENT body2 (#PCDATA)>
[ innerContent2
<!ELEMENT body3 (#PCDATA)>
]
]
]>
- Declaration
<?xml version="1.0" encoding="UTF-8"?>
<?XML version="1.0" encoding="UTF-8"?>
<?xMl version="1.0" encoding="UTF-8"?>
- Process Instruction (PI)
<?stylesheet type="text/xsl" href="/Content/Glossary/main.xsl"?>
<?HeaderName key1="value1" key2="value2" .... ?> // Notes : HeaderName is a must
<Invalid> e.g. !!![ERROR]!!!!
<? key1="value1" key2="value2" .... ?> // Without HeaderName is not allowed
Text For Character References
<textForCharacterReferences>aa</textForCharacterReferences>
<!-- These lines are all comment
The above text is "aa" , because ‘a’ = 97(10) =0x61(16)
&# + digit number + ; // decimal mode (10)
&#x + hex number(either A-F or a~f is OK ) + ; // hex mode (16)
-->
| < | < | 小于 |
| > | > | 大于 |
| & | & | 位 与 |
| ' | ' | 单引号 |
| " | " | 双引号 |
XML 的详细教程文档
https://www.cnblogs.com/cb0327/p/4967782.html
- 空内容
<aaa></aaa> // 空内容
<aaa>Hello</aaa> // 有内容
- 混合 子标签 + 文本
<root>
Hello World Line #1
bbb<Child>Hello</Child>aaa
Hello World Line #2
</root>
- 单标签
<?xml version="1.0" encoding="utf-8"?>
<plist version="1.0">
<a>content</a>
<b />
<c/>
</plist>
混合 子标签 + 文本
Namespace of XML:
h:
<table> <name>African Coffee Table</name> <width>80</width> <length>120</length> </table> <h:table> <h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table>

浙公网安备 33010602011771号