Introduced as part of the XML 1.0 specification, DTDs are the oldest constraint model around in the XML world. They're simply to use, but this simplicity comes at a price: DTDs are inflexible, and offer you little for data type validation as well.
XML Schema (XSD)
XML Schema is the W3C's anointed successor to DTDs. XML Schemas are literally orders of magnitude more flexible than DTDs, and offer an almost dizzying array of support for various data types. However, just as DTDs were simple and limited, XML Schemas are flexible, complex, and (some would argue) bloated. It takes a lot of work to write a good schema, even for 50- or 100-line XML documents. For this reason, there's been a lot of dissatisfaction with XML Schema, even though they are widely being used.
[prefix]:[element name]
鍏冪礌錛?br>root鍏冪礌蹇呴』鍖呭惈鎵鏈夋枃妗d腑鐨勫厓绱狅紝鍙兘鏈変竴涓猺oot鍏冪礌銆傚厓绱犲悕鍙兘浠ヤ笅鍒掔嚎鎴栧瓧姣嶅紑澶達紝涓嶈兘鏈夌┖鏍鹼紝鍖哄垎澶у皬鍐欍傚紑鍏冪礌蹇呴』鏈夊搴旈棴鍏冪礌錛堜篃鏈夌被浼糷tml鐨勭畝鍐欙紝濡?lt;img src="http://www.aygfsteel.com/images/xml.gif" />錛夈傛枃妗g敱DTD鎴杝chema鏉ラ檺鍒跺畠鏄惁鍚堟牸銆?/pre>灞炴э細
浠涔堟椂鍊欑敤灞炴э紵鍩烘湰鍘熷垯錛氬涓肩殑鏁版嵁鐢ㄥ厓绱狅紝鍗曞肩殑鏁版嵁鐢ㄥ厓绱犮傚鏋滄暟鎹湁寰堝鍊兼垨鑰呮瘮杈冮暱錛屾暟鎹渶鍙兘灞炰簬鍏冪礌銆備粬涓昏琚綋浣滄枃鏈紝瀹?lt;rss:author>Doug Hally</rss:author> <journal:author>Neil Gaiman</journal:author>鏄撴悳绱紝濂界敤銆傛瘮濡備竴鏈功鐨勭珷鑺傛弿榪般傜劧鑰屽鏋滄暟鎹富瑕佷綔涓哄崟鍊煎鐞嗙殑璇濓紝鏈濂戒綔涓哄睘鎬с傚鏋滄悶涓嶆竻妤氾紝鍙互瀹夊叏鐨勪嬌鐢ㄥ厓绱犮?/pre>鍛藉悕絀洪棿Namespaces錛?br>xml鐨勫懡鍚嶇┖闂存槸涓縐嶇敤涓涓壒瀹氱殑URI鏉ュ叧鑱擷ML鏂囨。閲岀殑涓涓垨澶氫釜鍏冪礌鐨勬柟娉曘傛剰鍛崇潃鍏冪礌鏄敱鍚嶅瓧鍜屽懡鍚嶇┖闂翠竴璧鋒潵璇嗗埆鐨勩傝澶氬鏉傜殑XML鏂囦歡閲岋紝鍚屼竴涓悕瀛椾細鏈夊涓敤閫斻傛瘮濡傦紝涓涓猂SS feed鏈変竴涓綔鑰咃紝榪欎釜浣滆呭悓鏃舵槸姣忎釜鏃ヨ鐨勩傝櫧鐒惰繖浜涙暟鎹兘鐢╝uthor鍏冪礌鏉ヨ〃紺猴紝浣嗕粬浠笉搴旇琚綋浣滃悓涓涓?em>綾誨瀷鐨勬暟鎹傚懡鍚嶇┖闂村緢濂界殑瑙e喅浜嗚繖涓棶棰橈紝鍛藉悕絀洪棿璇存槑涔﹁姹備竴涓墠緙鍜屽敮涓鐨刄RI鑱斿悎璧鋒潵鍖哄垎涓嶅悓鍛藉悕絀洪棿閲岀殑鍏冪礌銆傚http://www.neilgaiman.com/entries浣滀負URI錛岃仈鍚堝墠緙journal鐢ㄦ潵琛ㄧず鏃ュ織鐩稿叧鐨勫厓绱犮?br><rdf:RDF xmlns:rss="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:journal="http://www.neilgaiman.com/entries">錛岀劧鍚庡氨鍙嬌鐢ㄤ簡錛?br><rss:author>Doug Hally</rss:author> <journal:author>Neil Gaiman</journal:author>瀹為檯涓婂湪浣跨敤鍛藉悕絀洪棿鍓嶇紑鐨勬椂鍊欏啀瀹氫箟涔熷彲浠ョ殑錛?br><rss:author xmlns:rss="http://www.w3.org/1999/02/22-rdf-syntax-ns#">Doug Hally</rss:author>
濡傛灉鍚嶅瓧娌℃湁鍛藉悕絀洪棿錛屼笉浠h〃鍦ㄩ粯璁ゅ懡鍚嶇┖闂翠腑錛岃屾槸xml澶勭悊鍣ㄤ互鍦ㄤ換浣曞懡鍚嶇┖闂翠互澶栨柟寮忚В閲婁粬銆傝澹版槑榛樿鍛藉悕絀洪棿鐨勮瘽灝變笉鐢ㄥ悗闈㈠啋鍙烽儴鍒嗭紝濡?lt;Insured xmlns="浣跨敤鐨勪竴浜涙湳璇?/strong>:
The name of a namespace (such as http://www.ibm.com/software) is the namespace URI.
The element or attribute name can include a prefix and a colon (as in prod:Quantity). A name in that form is called a qualified name, or QName, and the identifier that follows the colon is called a local name. If a prefix is not in use, neither is the colon, and the QName and local name are identical.
An XML identifier (such as a local name) that has no colon is sometimes called an NCName. (The NC comes from the phrase no colon.)
Entity references:
鐢ㄦ潵澶勭悊杞箟瀛楃錛岃娉曟槸& [entity name] ;XML瑙f瀽鍣ㄧ鍒拌繖縐峞ntity reference錛屽氨浼氱敤瀵瑰簲鐨勫兼浛鎹㈡帀浠栥傚<錛?lt;錛?>(>),&(&),"("),'(')銆傛敞鎰廵ntity reference鏄敤鎴峰彲瀹氫箟鐨勩傛瘮濡傚澶勭敤鍒扮増鏉冩彁紺猴紝鑷繁瀹氫箟鍚庝互鍚庢洿鏀瑰氨鏂逛究浜嗭細<ora:copyright>&OReillyCopyright;</ora:copyright>銆傞櫎浜嗙敤鏉ヨ〃紺烘暟鎹腑鐨勫鏉傛垨鐗規畩瀛楃澶栵紝entity reference榪樹細鏈夋洿澶氱敤閫斻?/p>
涓嶈В鏋愮殑鏁版嵁錛?br>褰撲紶杈撳ぇ閲忔暟鎹粰搴旂敤涓斾笉鐢▁ml瑙f瀽鐨勬椂鍊欙紝CDATA灝辨湁鐢ㄤ簡銆傚綋澶ч噺鐨勫瓧絎﹂渶瑕佺敤entity reference杞箟鐨勬椂鍊欙紝鎴栫┖鏍煎繀欏諱繚鐣欑殑鏃跺欙紝浣跨敤CDATA銆?lt;![CDATA[鈥?]]>