You are on page 1of 22

XML Lessons

http://www.dingos.cn

XML Lessons
( 1 )

http://www.dingos.cn/index.php?topic=1695.0

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

XML Lessons

1.1
1.1.1
1.1.2
1.2
1.2.1
1.2.2
1.2.3

1.1
1.1.1
1.1.2
1.1.3
1.1.4
1.1.5
1.1.6

XML ...................................................................................................................... 1
................................................................................................................ 1

........................................................................................................................... 1
........................................................................................................................... 1
XML .......................................................................................................................... 1

............................................................................................................ 1
................................................................................................................... 2
XML .......................................................................................................... 2
XML ............................................................................................................... 3
........................................................................................................................... 3

................................................................................................................... 3
....................................................................................................................... 3
............................................................................................................................... 4
....................................................................................................................... 6
........................................................................................................................... 6
................................................................................................................... 7

XML .................................................................................................................. 8

1.1

XML .............................................................................................. 8

1.2

XML ........................................................................ 8

1.1
1.1.1
1.1.2
1.1.3
1.1.4
1.1.5
1.1.6

1.1
1.1.1
1.1.2
1.2
1.2.1

XML .................................................................................................................... 10
......................................................................................................................... 10

......................................................................................................................... 10
..................................................................................................................... 10
.......................................................................................................... 10
............................................................................................... 10
..................................................................................................................... 13
...................................................................................................... 13
XML .................................................................................................................... 15
......................................................................................................................... 15

......................................................................................................................... 15
...................................................................................................... 15
....................................................................................................... 16

......................................................................................................................... 16

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

XML ......................................................................................................... 17

1.1

................................................................................................................................. 17

1.2

................................................................................................................................. 17

1.3

CDATA ............................................................................................................................ 18

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

1.1

XML

1.1.1

XML

XML Windows Web


Internet
XML W3C
XML XML

XML XML
XML
XML
XML XML XML
MSXML

1.1.2

XML
<tag>
<>
?![<>

1.2

XML

1.2.1

XML XML XML


XML XML 1.0
XML 1.0 1.1 1.0
XML XML 1.1.<?xml
version=,?>
<?xml version="1.0"?>

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

XML XML

1.2.2

ISO
ASCII 7 8

UTF-8 UTF-16 2

encoding

<?xml version="1.0" encoding="utf-8"?>

1.2.3

XML

XML
XML .xml
XML
XML
XML
XML

.xml
XML IE
Netscape

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

1.1

XML

1.1.1

XML <
>>
>
HTML XML

<>
<
<tag>Some Value</tag>
<tag></tag>

XML XML

<title>The Distinguished Gentleman</title>


<director>Jonathan Lynn</director><length>112 Minutes</length>

1.1.2

HTML XML XML


CASE, Case, case
<>


- <Country> <_salary>

- <OperatingSystem>
- <L153>
- <TV-Rating>
<Chief_Accountant>
xmlXML XML

http://www.dingos.cn

XML Lessons

http://www.dingos.cn


[hourly salary]
HourlySalary DateOfBirth

1.1.3

XML

<rectangle>A rectangle is a shape with 4 sides and 4 straight


angles</rectangle>

XML
XML
<rectangle>A rectangle is a shape with 4 sides and 4 straight
angles</rectangle>
<square>A square is a rectangle whose 4 sides are equal</square>

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

<rectangle>A rectangle is a shape with 4 sides and 4 straight angles


<square>A
square
is
a
rectangle
whose
4
sides
are
equal</square></rectangle>

<geometry><rectangle>A rectangle is a shape with 4 sides and 4


straight angles
</rectangle><square>A square is a rectangle whose 4 sides are
equal</square></geometry>

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

XML
<?xml version="1.0" encoding="utf-8"?><geometry><rectangle>A
rectangle is a shape with 4 sides and 4 straight
angles</rectangle><square>A square is a rectangle whose 4 sides
are equal</square></geometry>
XmlDocument DocumentElement XML

1.1.4

XML HTML

<dinner></dinner>

<dinner />

1.1.5

XML

<title>The Distinguished Gentleman</title> <director>Jonathan


Lynn</director> <length>112 Minutes</length>

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

<title>The Distinguished Gentleman</title>


<director>Jonathan Lynn</director>
<length>112 Minutes</length>
XML

1.1.6

XML

<Smile>Please smile to the camera</Smile>


<English>Welcome to our XML Class</English>
<French>Bienvenue notre Classe XML</French>
English Smile
English Smile
English </Smile>
<Smile>Please smile to the camera<English>Welcome to our XML
Class</English></Smile>

<smile>Please smile to the camera


<English>Welcome to our XML Class</English>
</smile>

<Smile>Please smile to the camera


<English>Welcome to our XML Class
</Smile>
</English>
English Smile Smile

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

1.1

XML

XML

XML
DataGridView XML
Windows

1.2

XML

XML HTML
XML
CSS
CarYear
{
display: block;
font-weight: bold;
font-size: 16pt;
color: white;
font-family: Garamond, Georgia, 'Times New Roman' , Serif;
background-color: #990000;
}
Make
{
font-size: 10pt;
font-family: Verdana, Tahoma, Arial, Sans-Serif;
background-color: white;
}
Model
{
font-size: 10pt;
font-family: Verdana, Tahoma, Arial, Sans-Serif;
background-color: white;
}
PartNumber
{
font-size: 10pt;
color: #ff0066;

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

font-family: Verdana, Tahoma, Arial, Sans-Serif;


background-color: white;
display: block;
}
PartName
{
font-size: 10pt;
color: #ff0066;
font-family: Verdana, Tahoma, Arial, Sans-Serif;
background-color: white;
display: block;
}
UnitPrice
{
font-size: 10pt;
color: #ff0066;
font-family: Verdana, Tahoma, Arial, Sans-Serif;
background-color: white;
display: block;
}
XML
<?xml:stylesheet href="cpap.css" type="text/css" ?>

http://www.dingos.cn

XML Lessons

http://www.dingos.cn

1.1

XML

1.1.1

XML

1.1.2

<Director> Director

1.1.3

<Director>Jonathan
Lynn</Director>Jonathan Lynn Director

<?xml version="1.0" encoding="utf-8" ?>


<Employees>
<Employee>
<FullName>Lydia Thomason</FullName>
<Salary>25.64</Salary>
<DepartmentID>1</DepartmentID>
</Employee>
<Employee>
<FullName>June Grath</FullName>
<Salary>16.38</Salary>
<DepartmentID>4</DepartmentID>
</Employee>
</Employees>
Salary DepartmentID

1.1.4

<?xml version="1.0" encoding="utf-8" ?>


<Employees>
http://www.dingos.cn

10

XML Lessons

http://www.dingos.cn

<Employee>
<FullName>Sylvie <Bellie> Aronson</FullName>
<Salary>25.64</Salary>
<DepartmentID>1</DepartmentID>
</Employee>
<Employee>
<FullName>Bertrand Yamaguchi</FullName>
<Salary>16.38</Salary>
<DepartmentID>4</DepartmentID>
</Employee>
</Employees>
XML

<FullName>Sylvie <Bellie> Aronson</FullName>


<Bellie><Bellie>
XML
&lt
&gt;
<?xml version="1.0" encoding="utf-8" ?>
<Employees>
<Employee>
<FullName>Sylvie &lt;Bellie&gt; Aronson</FullName>
<Salary>25.64</Salary>
<DepartmentID>1</DepartmentID>
</Employee>
<Employee>
<FullName>Bertrand Yamaguchi</FullName>
http://www.dingos.cn

11

XML Lessons

http://www.dingos.cn

<Salary>16.38</Salary>
<DepartmentID>4</DepartmentID>
</Employee>
</Employees>

XML

&apos;

'

&lt;

<

&gt;

>

&quot;

"

&amp;

&

"

"

&

&

'

'

http://www.dingos.cn

empty

12

XML Lessons

http://www.dingos.cn

<

<

>

>

B
B
i
i

XML

1.1.5

<?xml version="1.0" encoding="utf-8"?>


<Videos>
<Video>
<Title>The Distinguished Gentleman</Title>
<Director>Jonathan Lynn</Director>
</Video>
</Videos>
Video

1.1.6

XML

<?xml version="1.0" encoding="utf-8"?>


<Videos>
<Video>
<Title>The Distinguished Gentleman</Title>
<Director>Jonathan Lynn</Director>
<Length>112 Minutes</Length>
<Format>DVD</Format>
<Rating>R</Rating>

http://www.dingos.cn

13

XML Lessons

http://www.dingos.cn

</Video>
<Video>
<Title>Her Alibi</Title>
<Director>Bruce Beresford</Director>
<Length>94 Mins</Length>
<Format>DVD</Format>
<Rating>PG-13</Rating>
</Video>
</Videos>

Title Director Video Video


Title Director

http://www.dingos.cn

14

XML Lessons

http://www.dingos.cn

1.1

XML

1.1.1

XML XML

1.1.2

ISBN Video

<Video>
<ISBN>0-7888-1623-3</ISBN>
</Video>
ISBN Video ISBN Video

<Video ISBN="0-7888-1623-3">
ISBN Video

http://www.dingos.cn

15

XML Lessons

1.2

http://www.dingos.cn

1.2.1

0 1
XML

<?xml version="1.0" encoding="utf-8" ?>


<Videos>
<Video ISBN="0-7888-1623-3">
<Title Screenplay="Marty Kaplan">The Distinguished
Gentleman</Title>
<Director>Jonathan Lynn</Director>
<Actors></Actors>
<Length>112 Minutes</Length>
<Format>DVD</Format>
<Rating>R</Rating>
</Video>
<Video>
<Title WrittenBy="Charlie Peter">Her Alibi</Title>
<Director>Bruce Beresford</Director>
<Length>94 Mins</Length>
<Format>DVD</Format>
<Rating>PG-13</Rating>
</Video>
</Videos>

<Video><ISBN>0-7888-1623-3</ISBN></Video>
<Video />

<Video ISBN="0-7888-1623-3" />

http://www.dingos.cn

16

XML Lessons

http://www.dingos.cn

1.1

XML

XML

<?xml version="1.0" encoding="utf-8"?>


<Videos>
<Video>
<Title>The Distinguished Gentleman</Title>
<Director>Jonathan Lynn</Director>
<Length>112 Minutes</Length>
<Format>DVD</Format>
<Rating>R</Rating>
</Video>
<Video>
<Title>Her Alibi</Title>
<Director>Bruce Beresford</Director>
<Length>94 Mins</Length>
<Format>DVD</Format>
<Rating>PG-13</Rating>
</Video>
</Videos>

1.2

XML XML

XML

<!-- Blah Blah Blah -->


<!-- -->

<?xml version="1.0" encoding="utf-8"?>


<Videos>
<Video>
<!-- In this collection, we will keep each title "as is" -->
<Title>The Distinguished Gentleman</Title>
<Director>Jonathan Lynn</Director>
<Length>112 Minutes</Length>
http://www.dingos.cn

17

XML Lessons

http://www.dingos.cn

<Format>DVD</Format>
<Rating>R</Rating>
</Video>
<Video>
<Title>Her Alibi</Title>
<Director>Bruce Beresford</Director>
<Length>94 Mins</Length>
<Format>DVD</Format>
<Rating>PG-13</Rating>
</Video>
</Videos>

1.3

CDATA

XML

XML
CDATA
<![CDATA[]]>

http://www.dingos.cn

18

XML Lessons

http://www.dingos.cn

<![CDATA[ Blah Blah Blah ]]>


<![CDATA[ ]]> XML

<?xml version="1.0" encoding="utf-8"?>


<Videos>
<![CDATA[<VideoCollection>Personal Collection of
Movies</VideoCollection>]]>
<Video>
<Title>The Distinguished Gentleman</Title>
<Director>Jonathan Lynn</Director>
<Length>112 Minutes</Length>
<Format>DVD</Format>
<Rating>R</Rating>
</Video>
<Video>
<Title>Her Alibi</Title>
<Director>Bruce Beresford</Director>
<Length>94 Mins</Length>
<Format>DVD</Format>
<Rating>PG-13</Rating>
</Video>
</Videos>

http://www.dingos.cn

19