XML syntax [focus]
I. Introduction & Overview
Why talk about XML: In order to use the program more professional profile
XML called the Extensible Markup Language, which means Extensible Markup Language.
Java programming language: the first compiler implementation
XML markup language: the language of the label consisting of
effect:
save data
Save the program configuration information (which applets to run, run after which the applet)
Getting two cases: quickly create XML file
XML in the src helpful information
XML project under the root directory of the lack of help
III. Documentation statement
All first line of the XML document is a document declaration:
Documentation must be declared in the first line of the document;
IV. Elements (tags)
XML is a markup language: composed by a label
Label format:
<Start label> </ end tags>
E.g:
<bean></bean>
- Elements of the case, must be paired general (must start with end)
- Between the start and end tags: ① ② sub-content body text label (sub-element)
3. Empty elements: empty element tag is only the beginning, but no end tag, but the elements must own closed
Empty elements: no body text content, there is no sub-elements
note:
- Naming elements:
a) strictly case-sensitive (IDEA automatically synchronized)
b) no spaces
Schema will be used later to explain the constraints: C) is not recommended at present use a colon
d) it is not recommended to start with XML, xml, Xml
e) does not recommend the use of Chinese
2. Format good XML document must have only one root element.
The root element: the root tag, wrap all the other label content in XML
A document must have only one root tag.
V. attribute (Java member variables)
Attribute format:
<1 start tag attribute name = "attribute value 1" 2 attribute name = "attribute value 2"> </ tag end>
Precautions:
- The same tag, the property can not be duplicate names
2. The property name can not use spaces, colon and other special characters, and must start with a letter
3, pay attention to Chinese em space when defining attribute
<?xml version="1.0" encoding="UTF-8" ?>
<plist>
<person name="小田田" sex="男" age="28"></person> <person name="小关关" sex="男" age="23"></person> <person name="小润润" sex="男" age="23"/> </plist>
VI. Notes
Note: to the programmer, the description information
XML comments:
Format: <-! XML comment ->
Comment out the first line on XML
Join / Uncomment shortcuts: ctrl + /
VII. Escape character
In XML, some characters are XML syntax as a structure to use.
<bean x=””>
<?xml version="1.0" encoding="UTF-8" ?>
<beans>
1<2
2>1
"
'
&
</beans>
Eight. CDATA area
Help me avoid checking XML, CDATA area can put plain text.
<?xml version="1.0" encoding="UTF-8" ?>
<exam>
<question> 1、问题1:以下哪个符号是大于号? A.> B.< C.! D.!= </question> <question> <![CDATA[ 1、问题1:以下哪个符号是大于号? A.> B.< C.! D.!= ]]> </question> </exam>
Shortcuts: CD
Read data from XML with Java programs
Write data to the XML in the Java programming
CDATA data operation is troublesome area
Please give their efforts a point like oh!
A little progress every day ~~~~~ `
Source: http://www.1994july.club/