Search | Contact | Link To Us  

     VB .NET     

.NET Defined
OOP with VB
VB Language
Win Forms
Windows Controls
ADO .NET
User Controls
File Handling
Multithreading
Deployment
XML Web Services
Essential XML
  -Well-Formed Doc's
  -Valid Documents
Resources
Discussions
ASP.NET
About



Advertisement











    Home> Essential XML

Extensible Markup Language (XML)

The markup language most widely used today is undoubtedly Hyper Text Markup Language (HTML), which is used to create Webpages. A Markup language describes the structure of the document. HTML is based on Standard Generalized Markup Language (SGML), which is an application of SGML. Webpages designed using HTML are designed using HTML predefined tags. These days, as Internet is used widely as general form of communication and as transferring data over the Internet is becoming more intensive and handling that data more complex many Web Developers are turning to XML as their alternative to HTML. It's worth having a brief overview of this wonderful new Markup Language which is changing the way data is handled on the Internet.

What is XML?

XML is a meta-markup language which means that it lets us create our own markup language (our own tags).

XML is popular for the following reasons:

  • It Allows Easy Data Exchange
  • It Allows to Customize Markup languages
  • Makes the data in the document Self-Describing
  • Allows for Structured and Integrated data
The current version of XML is 1.0 and XML is case sensitive. Let's follow this meta-markup language with an example. Save the following code with a .xml extension.

<?xml version="1.0" encoding="UTF-8"?>
<DOCUMENT>
<WELCOME>
Welcome to XML
</WELCOME>
</DOCUMENT>>

Breaking the above code for understanding:

The document starts with the XML processing instruction <?xml version="1.0" encoding="UTF-8"?>
All XML processing instructions should start and end with ?
xml version="1.0" means the version of XML, which is currently 1.0
UTF-8 is a 8-bit condensed version of Unicode
The document starts with the <DOCUMENT> element which may or may not contain other elements within it and should always end with </DOCUMENT>. All other elements should be between <DOCUMENT> and </DOCUMENT> making <DOCUMENT> the root element for this XML page.
The next element is <WELCOME> between the <DOCUMENT> and </DOCUMENT> and which contains a message, Welcome to XML.

The above code when opened in a browser looks like the image below.

To format the content of the elements created in the document we use a style sheet to tell the browser the way the document should be. Alternatively, programming languages like Java and JavaScript can be used. Lets take a look how the above example looks when formatted using style sheet.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="style.css"?>
<DOCUMENT>
<WELCOME>
Welcome to XML
</WELCOME>
</DOCUMENT>

The above code includes a new line <?xml-stylesheet type="text/css" href="style.css"?> which means that the type of style sheet being used is CSS (Cascading Style Sheet, XSL can also be used) and it's name is style.css.
The file style.css looks like this:  WELCOME{font-size:40pt;font-family:Arial; color:red}
This file states that it's customizing the <WELCOME> element to display it's content in a 40 pt font with arial as it's font and it's color as red.
You can customize different elements to display their content in different fonts and colors.
Make sure that the file style.css is saved in the same directory where the xml file is saved. The output after adding the style sheet looks like the image below.

XML is case sensitive, which means <WeLCOME> and </Welcome> are treated differently. <WELCOME> should be closed with a corresponding</WELCOME> tag.

  Privacy Policy | Terms of Use | Site Map | Contact

  © 2004-2007 Startvbdotnet.com. All rights reserved.