Você está na página 1de 2

c 




XML stands for Extensible Markup Language and is a language used for describing data.
Moreover, XML was not designed to do anything. Instead, it is used by other languages to
structure, store, and exchange data. The markup tags in XML are not predefined as they are in
HTML. This is why it¶s called an extensible language, because you can create your own markup
tags. By defining valid tags and semantic ± either using a document type definition (DTD) or its
successor the XML Schema ± it¶s possible to create new languages with XML. Some examples
of languages specified in XML are: XHTML, SOAP, and RSS.

c  

To make an XML document create an empty text file and give it a .xml file extension. The first
line in the document must be the XML declaration. This line defines the XML version and the
character encoding used in the document.

u 
  
   

This XML document will describe a book so the first tag is called book. Just as in XHTML the
tags are recognized by the angle brackets and all tags must have a closing tag (except for the
XML declaration). Unlike HTML, XML tags are not predefined. Any tag names can be used, but
they shouldn¶t contain spaces or start with numbers or punctuations. Either upper or lower case
letters can be used, as long as the opening and closing tags have same casing.

u 
  
   
u

u



This first element is called the root element and each XML document can have only one of them.
Inside the root two child elements are included: title and chapter. These are sister elements to
each other, because they have the same parent element. All elements can contain both text and
child elements.

u 
  
   
u


u   !u 

u"#$"  !u"#
u



c 
XML documents use a very simple and self-describing syntax. If you open up the document
created in the previous section in a browser it will be displayed as a tree without any stylistic
formatting. It is just data wrapped in tags. To make any use of the file a program has to be
written that accesses the data.

u 
  
   

u


u   !u 
u"#$"  !u"#
u



Keep in mind that XML has very strict rules regarding its structure. If there is an error in the
document, for example if a closing tag has been nested improperly, the browser will report the
error and won¶t display the document.

uuu%
&u
uu%
&uu
uu'  uu

å 

Elements can have four different content types. Below the title element has simple content,
which is also called text content. Book has element content, because it contains only elements
and no text. Chapter has mixed content, because it contains both text and elements. Finally, the
para tag has empty content. Elements with empty content can also be shortened as in XHTML,
by removing the end tag and including a slash before the closing bracket of the start tag.
u 
  
   
u



u 
 u 
u"#! 
 
u#u#
u#
u"#

u



Você também pode gostar