How to Design a XML Document Easily

An XML based document consists of XML tags which are nested within each other. Tags are used to represent the elements. In order to understand the design process of an XML document we should first understand these tags. There are two types of tags in an XML document. First are the tags which represent elements in the XML document. These are further classified into root element and child elements. Second are the processing instruction tags. We will discuss these later.

All documents must have a root tag and child elements are nested with in the root tag. Generally we use tags names which help in the description of the information contained in the tags. All the child elements can have sub children. Proper nesting of tags with respect to parent tag is necessary in XML based document.

Consider the following example which explains the format of xml document:


Processing instructions are used to pass information which is necessary to process the document or we can say they pass instructions or commands to the program or application which is processing the XML document.

There format is as below:
<? Processing instruction?>

To design the XML document we have to create an XML schema which defines the basic structural elements and attributes in the document. Apart from this it is the responsibility of XML schema to define the data types of elements and attributes in the XML document.

Also the number of child elements and their order is also decided in the XML schema. The elements of an XML schema can be simple type or complex type. Simple types are those which can have only text. Text can be any XML defined data type like string, date, time etc. Complex type elements can have other elements and attributes.

Following are the examples of defining simple type and complex type elements in a XML schema.

Syntax for defining a simple type element is:

<xs:element name="xx" type="yy"/>
Consider the following XML elements:

<firstname> john </firstname>
<lastname> raviz </lastname>
<age> 35 </age>

Corresponding part of XML schema would be

<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>

Now we will look into an example of complex type element. As we know complex type can have other elements and attributes. Consider the following case:

<firstname> john </firstname>
<lastname> raviz </lastname>

The corresponding element type definition for this complex element “student” would be

<xs:element name="student">
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>

Here we have two child elements: firstname and lastname. To ensure their order should be same in the XML document as they are declared we have included <sequence> indicator.
So above mentioned guidelines should be kept in designing an XML document.

SetApp - 100 Apps for everything you ever wanted to do on Mac

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.


Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.


| Generating XML Document Using Java servlet | How to Design a XML Document Easily |Understanding Advanced XML Concepts | Understanding Class Loaders in Java | Understanding The Basic Reasons for Development of XML | Understanding Various Methods of Formatting XML Data | Understanding XML Based Web Protocols | Working With ebXML – An Indepth Overview | XML Database Program – Knowing the Basic Concepts |


FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.



Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.



Add to My Yahoo!

Visit XML Training Material Guide Homepage




“Amazon and the Amazon logo are trademarks of, Inc. or its affiliates.”

Copyright - © 2004 - 2019 - All Rights Reserved.