曝光台 注意防骗
网曝天猫店富美金盛家居专营店坑蒙拐骗欺诈消费者
FODM – Introduction to XML 7/44
An XML markup tag
XML Syntax - Tags
FODM – Introduction to XML 8/44
<?xml version="1.0" encoding="ISO-8859-1"?>
<contact>
<name>
<firstname>Ronan</firstname>
<surname>O'Gara</surname>
</name>
<email>
<id>ronan.o-gara </id>
<server>mail.com</server>
</email>
<address>
<street>26 O'Connell St</street>
<postcode>27 011</postcode>
<town>Dublin</town>
<country>Ireland</country>
</address>
<comment>He’s a great rugby player!</comment>
</contact>
XML declaration
defines the XML version and the
character encoding used in the
document.
( In this case the document conforms to
the 1.0 specification of XML and uses the
ISO-8859-1 (Latin-1/West European)
character set. )
Root element of the document
"this document is a note“.
Child elements of the root
4 child elements of the root (to,
from, heading, and body):
End of the root element
XML Syntax - Tags
FODM – Introduction to XML 9/44
In XML, ALL elements must
have a closing tag
<name>
<firstname>Ronan</firstname>
<surname>O'Gara</surname>
</name>
XML Syntax - Tags
Note 1: In the example on the previous slide, the XML declaration did not have a
closing tag. The declaration is not a part of the XML document itself and
therefore it does not have a closing tag.
Note 2: <code/> is an alternative method to close the tag. Used for empty
elements only
FODM – Introduction to XML 10/44
XML tags are case sensitive
• In XML, the tag <Text> is different
from the tag <text>
• Opening and closing tags must be
written with the same case.
<Text>This is incorrect</text>
<text>This is correct</text>
In XML, all elements must be
properly nested within each other
like this
<b><i>This text is bold and italic</i></b>
In HTML, some elements can be
improperly nested within each other
like this:
<b><i>This text is bold and italic</b></i>
XML Syntax - Tags
FODM – Introduction to XML 11/44
All XML documents must have
a root element
•All other elements must be within this
root element
•All elements can have sub elements
(child elements)
•Sub elements must be correctly
nested within their parent element
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<element>
<subelement>.....</subelement>
</element>
</root>
Attribute values must always be
quoted
•XML elements can have attributes in
name/value pairs just like in HTML
•In XML the attribute value must
always be quoted
<?xml version="1.0" encoding="ISO-8859-1"?>
<contact sex=“male”>
<name>
<firstname>Ronan</firstname>
</name>
</contact>
XML Syntax – Tags Elements and Attributes
<?xml version="1.0" encoding="ISO-8859-1"?>
<contact sex=male>
<name>
<firstname>Ronan</firstname>
</name>
</contact>
FODM – Introduction to XML 12/44
XML Syntax – Tags Elements and Attributes
Adding spaces when editing: Will be displayed when
published :
26 O'Connell Street
With XML, white space is preserved.
When editing an element, several spaces will be displayed as only one space when
published
26 O Connell Street
FODM – Introduction to XML 13/44
XML Syntax – Tags Elements and Attributes
Inside tags (between attributes) -> No EFFECT
<contact sex=“male” birthday=“24/03/1966”>
<firstname>Ronan</firstname>
</contact>
<contact
sex=“male”
birthday=“24/03/1966”>
<firstname>Ronan</firstname>
</contact>
SAME
In the same way, indentation has different effects when it is used inside tags
(between attributes) and inside the content of the element.
FODM – Introduction to XML 14/44
XML Syntax – Tags Elements and Attributes
Inside content (outside brackets) -> Formatting is not preserved
中国航空网 www.aero.cn
航空翻译 www.aviation.cn
本文链接地址:
FODM Training(2)