XML

What is XML

  • XML stands for EXtensible Markup Language
  • XML is a markup language much like HTML
  • XML was designed to carry data, not to display data
  • XML tags are not predefined. You must define your own tags

XML is hierarchical, and as such the proper nesting of tag elements is crucial.

Example:

<?xml version=”1.0″?>
<MovieCatalog>
<movie>
<title>The Matrix</title>
<actors>
<actor>Keanu Reeves</actor>
<actor>Laurence Fishburne</actor>
</actors>
<director>Wachowski Brothers</director>
</movie>
</MovieCatalog>

Well Formed XML Documents:

A “Well Formed” XML document has correct XML syntax.The syntax rules are:

  • XML documents must have a root element
  • XML elements must have a closing tag
  • XML tags are case sensitive
  • XML elements must be properly nested
  • XML attribute values must be quoted

Valid XML Documents

A “Valid” XML document is a “Well Formed” XML document, which also conforms to the rules of a Document Type Definition (DTD).

The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements:

DTD for the above xml :

<!DOCTYPE MovieCatalog [
<!ELEMENT MovieCatalog (movie,title,actors+,director)>
<!ELEMENT actors(actor)>
<!ELEMENT movie (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT actors (#PCDATA)>
<!ELEMENT actor (#PCDATA)>
<!ELEMENT director (#PCDATA)>
]>

an XML based alternative to DTD called XML Schema can also be used.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: