Suposem el següent exemple:
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
XML utilitza una sintaxi molt auto-descripció.
Un pròleg defineix la versió de XML i la codificació de caràcters:
<?xml version="1.0" encoding="UTF-8"?>
La següent línia és el element arrel del document:
<bookstore>
La següent línia s'inicia un element <llibre>:
<book category="cooking">
Els llibres <> elements tenen 4 elements secundaris : <title>, <autor>, <any>, <> de preus.
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
La següent línia acaba l'element de llibre:
</book>
Documents XML es formen com arbres d'elements .
Un arbre XML s'inicia en un element arrel i les branques de l'arrel a elements secundaris .
Tots els elements poden tenir sub-elements (elements secundaris):
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
<child>
<subchild>.....</subchild>
</child>
</root>
Cap comentari:
Publica un comentari a l'entrada