XML
  Home arrow XML arrow Page 2 - XML Basics
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

XML Basics
By: Mamun Zaman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 19
    2007-09-05

    Table of Contents:
  • XML Basics
  • XML Tags and Conventions
  • More on Elements
  • XML Schema

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

    XML Basics - XML Tags and Conventions


    (Page 2 of 4 )

    XML tags have a naming convention. Tag names must not contain spaces, must not start with a number or punctuation character, and must not start with the letters "xml" in either capital or lowercase forms. Tag names can contain letters, numbers, and other characters.

    An XML document is said to be well-formed if it follows to the rules of the XML specification. The following list includes some examples of these XML rules:

    • All XML elements must have a closing tag. Do not omit the end tag. If an element has no data you can use the empty tag. For example,
      • <data>                             : not well-formed
      • <data>data 1</data>         : well-formed
      • <data/>                           : well-formed
      • <data></data>                  : well-formed
    • Matching Start and End tag. In XML all elements must be properly nested within each other like this:
      • <b><i>this is bold and italic</i></b>         : well-formed
      • <b><i>this is bold and italic</b></i>         : not well-formed
    • Ensure that a root element exists that encloses the entire document body. This root element makes the processing of the XML document easier when traversing the relevant tree structure.
    • In XML the attribute value must always be quoted. Use double quote marks if the value of the attribute contains single quote marks and vice versa.
      • <actors name='Frank "Riddler" Gorshin'>
      • <actors name="Frank 'Riddler' Gorshin">
    • Tag and attribute names are case-sensitive. So, <firstname>, <Firstname> and <FirstName> are different tags.

    To be of practical use, an XML document needs to be valid. The XML specification defines an XML document as valid if it has an associated DTD, Document Type Declaration, also if the document complies with the constraints defined in the DTD. A DTD is like the vocabulary and syntax rules for your XML documents. A DTD defines the data structure of an XML document, such as the order in which the tags should appear, and which tags and how many tags are to be specified. Companies that exchange XML documents can check them with the same DTD.

    DTD describes elements. It uses the following syntax:

    <!ELEMENT name-of-the-element description-of-the-element>

    For our Book XML example we can define the <book> element as follows:

              <!ELEMENT book (title, author, year, price)>

    For the title the DTD definition is:

              <!ELEMENT title (#PCDATA)>

    #PCDATA and CDATA are pre-defined element types.

    #PCDATA is also called parsed character data and is processed or parsed by XML parsers. This character data is to be analyzed. Child elements and character data can be included in the element.

    CDATA represents character data that is not analyzed and is not parsed by XML parsers.

    Attributes can be declared using the pattern:

    <!ATTLIST element-name attribute-name attribute-type default-value>

    The id attribute in above XML example can be declared as:

    <!ATTLIST title id CDATA "0">

    Here, the Element-name is title, Attribute-name is id, Attribute-type is CDATA (in other words, is character data) and the default value is "0."

    More XML Articles
    More By Mamun Zaman


       · its very good to understand how and why the xml is used extensivly hope it is more...
       · Whenever i think about XML i think it's too hard by reading these article i get some...
     

    XML ARTICLES

    - Path, Predicates, and XQuery
    - Using Predicates with XQuery
    - Navigating Input Documents Using Paths
    - XML Basics
    - Introduction to XPath
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands
    - Creating an XUL App Installer
    - Overlays in XUL
    - Skinning Your Custom XUL Applications


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway