XML foundation

Recommended sites: http://www.w3school.com.cn/xml/index.asp

to sum up:

1. Takes note of the XML declaration did not close the tab. This is not an error. XML declaration not part of itself. It is not an XML element does not require a closing tag

2. XML document must have a root element

3. The five entity references: In XML, only the characters "<" and "&" is indeed illegal

&lt; < Less than
&gt; > more than the
&amp; & And number
&apos; ' apostrophe
&quot; " quotation marks

4. Windows applications, typically a pair of line feed characters stored: carriage return (CR) and line feed (LF)

5. Element content : because they contain other elements;   text : since it contains only text.

6. naming rules:

         Avoid "-" character. If you name this way: "first-name", some software will think you need to extract the first word.

         Avoid. "" Characters. If you name this way: "first.name", some software may think that "name" is the object "first" of the property.

         Avoid ":" character. Colon will be converted into namespace to use (described later).

7. attribute values ​​must be surrounded by quotation marks, but single or double quotes may be used

8. In HTML, the property is very convenient to use them, but in XML, you should try to avoid using property. If the information feels like data, use sub-element of it.

9. Avoid XML attributes:

      Some of the problems caused by the use of attributes:

  • Attributes can not contain multiple values ​​(elements can)
  • Attributes can not describe the tree structure (elements can)
  • Properties can not be extended (for future changes)
  • Property is difficult to read and maintain

10. The legal XML document is a "good form" of XML documents, to comply with the same document type definition (DTD) syntax rules:

11. Verify that the XML document: <! DOCTYPE note SYSTEM "Node.dtd">

12. XML DTD

  <!DOCTYPE node[

  <!ELEMENT node  (to,from)>

  <!ELEMENT to (#PCDATA)>

  <!ELEMENT from (#PCDATA)>

      ]>

13. XML Schema

      <xs:element name="note">

    <xs:complexType>

      <xs:sequence>

        <xs:element name="to"   type="xs:string"/>

        <xs:element name="from"   type="xs:string"/>

      </xs:sequence>

    </xs:complexType>

      </xs:element>

14. Only in Internet Explorer, you can validate XML in accordance with DTD. Firefox, Mozilla, Netscape and Opera can not do this.

15. Use CSS to display XML <? Xml-stylesheet type = "text / css" href = "cd.css"?>

16. XSLT (eXtensible Stylesheet Language Transformations) is the preferred XML Stylesheet Language. <?? Xml-stylesheet type = "text / xsl" href = "simple.xsl">, the link to the XML file XSL file:

Reproduced in: https: //www.cnblogs.com/gorgeous1314/archive/2012/07/16/2593776.html

Guess you like

Origin blog.csdn.net/weixin_33826268/article/details/93265667