Validating XML Document using Internal DTD

In this post we will create an XML document and validate the document using DTD. The Document Type Definition( DTD) tell us about the building blocks of a XML document. Hence, it is used for validating the XML documents.


To create a XML document for BOOKSTORE  and write the DTD information before the XML content in the same document.

Then we validate the document using a software tool or an online XML Validator. For this exercise we are using Net Beans, so you may also like to get Net Beans IDE from Oracle or

When you create a new Project in Net Beans, Click the new document option, highlighted in below figure using the circle.


Standard Navigation - NetBeans IDE
Standard Navigation – NetBeans IDE
A New File dialog box will open, in which on the left block , has different categories and right-hand block, there is a list of documents for the selected category.
Choose XML category and then Select XML Document for the XML category.
Choose XML Document
Choose XML Document
We are ready to write our first XML document and it is also possible to validate the XML document using NetBeans IDE.
Note: If you do not see XML category then you should check for Updates for NetBeans IDE.


Write the following XML information and save the file as BOOKSTORE.xml file.

<?xml version="1.0" encoding="UTF-8"?>
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.




The document starts with DTD information enclosed within < [  …… ] >  and then the rest of the document is XML tags.

Note: XML is case sensitive and tag names must be consistent throughout the document.

Validating the XML

To validate the XML Document using NetBeans, Right-Click the XML file and Click Validate XML.

Validate XML Document
Validate XML Document

If the document is well-formed, then we will get following output.

Validation Successful
Validation Successful

If the validation is not successful you need to make the necessary changes in order to make the XML document well-formed.

DBMS Exercises

DBMS exercises involves a construction of an E-R Model and then converting that ER Model to Relational model with database schema and relations.

You then have to learn how to construct various type queries to get desired results from the constructed databases.

On this page, you will find 4 different databases to construct and will have to answer questions related to each particular database to test your learning. You can check your answers with the solution to each question given below and know how much you learned.




JavaScript examples

JavaScript is a browser-based scripting language. With JavaScript, you add behavior to the HTML documents and control the browser or change the HTML document.

The best way to learn JavaScript is to try many examples. JavaScript is also a complex programming language, it is not easy to learn JavaScript just because it is a browser language. You must practice lots of examples.

The examples are divided broadly into two categories – basic examples and object-oriented examples. The basic example demonstrates the fundamental concepts of JavaScript and object-oriented examples, you learn about object-oriented programming concepts.


You need to complete certain prerequisites to get started with JS examples. These are tools and learning resources to help you learn JavaScript efficiently.

  • JavaScript tutorial – you must be familiar with JavaScript concepts and the best way to learn is either visit our JavaScript tutorial page or get a good easy to follow JavaScript book with examples.
  • Notepad – to write programs you need a text editor and browser can interpret the scripts easily. Download a new editor like Bracket, Sublime Text, Notepad++ or use builtin text editors – Notepad or Text Edit in Mac.
  • Browser – you need to install a browser to test you JavaScript code. You can download free browsers from internet like Chrome, Mozilla Firefox, UC Browser, Microsoft Edge, etc.

JavaScript exercises

Sub topics for JavaScript listed below.

JavaScript Basic Examples

JavaScript Object Exercises

JavaScript Algorithm Examples

JavaScript Projects

JavaScript References

C++ Examples

This page contains C++ example programs for practice. C++ is a different language than C programming because it supports object-oriented programming including C features.

The example programs are organized based on topics, not according to C++ language features. Before you start practicing the examples, go through the list of prerequisites.


Some of the prerequisites are necessary to try these C++ examples.

  • C++ Tutorial – you must be familiar with C++ language concepts before practicing the example programs. You can either learn from our C++ tutorial or get a good C++ programming book to learn the fundamentals. We recommended some good C++ books at the next section on this page.
  • C++ Compiler – this is most important prerequisite to practice your program. All the program in this page is written using Dev-C++ compiler or Turbo C++ 3 compiler. Read the documentation of your compiler and check the compatibility with your system before installing it. You can install development packages in OS like Linux.
  • Pen and Paper – some program need you to verify the output manually, especially the math programs. A pen and paper is the best method to check your outputs, for your new input values.

C++ Examples

List of sub topics for C++ language.

C++ Math Examples

C++ String Examples

C++ Finance Related Programs

C++ Data Structures Examples

Java Examples

Java is another general purpose programming language and supports object-oriented programming concepts like polymorphism, inheritance, etc.

Java was created by Sun Microsystems and since then many programmers use Java programming language to write network-based applications and business applications. You can also write games using Java programming language.

A list of Java programs is given below for the following purpose

  • Learn to program in Java by practicing these programs.
  • Learn the Java programming concepts using these examples.
  • Write similar programs on your own.

Prerequisites for Java Examples

Programming is all about doing, not just learning concepts and syntax of the programming languages. To learn Java you must use the practical approach – practice as many example programs you can. This will lay a strong foundation for you to learn higher and complex programs. To practice Java you need following.

  • Java Compiler – there is two way to install a Java compiler. First, you can install NetBeans or Eclipse with latest Java Development Kit ( JDK ). Second, Install the latest JDK version and work with command line utility.
  • Java Tutorial – before you practice example programs, learn the basic Java concepts to get started.
  • Pen and Paper – if you try new inputs for example Java programs and want to verify the results, make use of  pen and paper and solve the problem manually to verify outputs. Especially, in case of math programs it is true.

Java Example Programs

Topics for Java program listed here.

Java Math Programs

Java String Programs

Java Operators

Java Arrays

Java OOP Examples


DBMS is Database Management Systems is subject related to storage and retrieval of data from physical media. Read the DBMS tutorial topics and try to do the assignments.

About DBMS Tutorial

In this tutorial, you will learn all the concepts of DBMS and do assignment problems and exercises that come with the DBMS tutorial. The solution of each assignment is provided with the assignments. However, we encourage you to try to solve the problems on your own and then compare the results.

This tutorial is for beginners as well as advanced DBMS learners. There is no prerequisite to learn from this DBMS tutorial, but you must install a DBMS software to perform the SQL labs to get hands-on experiences.

DBMS Tutorial Topics

VB 6 Projects

Visual Basic 6 is a GUI based object-oriented programming language.

You can develop software with visual basic much faster than other programming languages. Visual basic follow the rapid application model also known as RAD model.

Doing projects is a great way to learn visual basic programming. A visual basic project not only gives you an idea about software development, but also teaches you project planning and process involved in finishing the project successfully.


To take maximize your learning, you must complete these prerequisites because visual basic seems to be an easy programming language, but it is not.

  • VB 6 Tutorial – you must be familiar with VB IDE and coding practices before creating your first project. You can do this in two ways – one, visit our VB tutorial page or read a visual programming book.
  • VB 6 IDE – install visual basic 6 software to create your project. Read the Visual basic 6.0 installation guide.
  • Microsoft Access – this is necessary for connecting your project to a data source, only if its a project requirement. For some projects you can use Microsoft Excel or SQL as the data sources.

VB 6 Examples

VB6 Database Projects

VB6 Attendance Management

VB6 Programs

Recommended Books

Whether you are a student or self-learner, it is hard to learn programming without a good book. I recommend few good books here which has detailed information about Visual Basic 6.0 programming. It is also necessary because Microsoft has stopped supporting Visual basic 6; now they have more advanced version of visual basic in the form of VB.Net and other versions. However, the language of modern visual basic is more or less the same.

C Tutorial

C is a programming language developed at AT & T’s Bell Laboratories of the USA in 1972. It was designed and written by Dennis Ritchie and Ken Thompson.


Absolutely no prior knowledge is required to learn C programming. Each topic has many lessons and examples that you can practice and learn.

The first step in learning C programming is to install a C compiler for practice. Learning programming is all about practice coding. The more you practice, the more you will learn.

C Tutorial Topics

List of C programming lessons given below. Learn in top to bottom order.

Recommended Books

Sometimes it is difficult for a self-learner to master programming without proper guidance. As a learner you are totally confused how to begin learning, it happens to most of us.

Lectures are good, but always forgotten when you are out of classroom or when you have finished watching videos. So, all you need is to slowly understand and absorb the concepts and workout examples of each topic in C programming yourself.

Books are your best friend when you are learning by yourself.

Here we recommend few books to get started with C programming language.

Data Structure – Binary Tree Concepts

A binary tree is a special kind of tree and important in computer science. There is plenty of real-world application of binary trees. The scope of this lesson is limited to the learning the binary tree concepts.

Learn Tree Basics

Informal definition

A tree is called a binary tree if it has the following properties.

  • It is an empty tree with no nodes.
  • The tree has a root node, left sub-tree and right sub-tree.
  • The sub-trees are binary tree themselves.

Strictly Binary Tree

Suppose there is a binary tree with right sub-tree and left sub-tree. The sub-trees are in turn non-empty, then such a binary tree is called a strictly binary tree.

Strictly Binary Tree - Binary Tree Concepts
Strictly Binary Tree – Binary Tree Concepts

In the above figure, one is a strictly binary tree and the second tree is not a strictly binary tree, but it is certainly a binary tree and satisfy all the properties of a binary tree.

Complete Binary Tree

A complete binary tree has a level L and all its leaf nodes are available at level L. At each level the complete binary tree contains 2Lnodes.

Let us show this with an example,

Complete Binary Tree - Binary Tree Concepts
Complete Binary Tree – Binary Tree Concepts

The root is at level 0, therefore, L = 0 and 2^L = 2^0 = 1.

Conversion of a Binary Forest into a Binary Tree

Suppose we have a forest with two trees as follows,

Forest with Two Trees - binary tree concepts
Forest with Two Trees
&T1 = { 1,2,3,4,5,6}\\
&T2 = { 7,8,9,10,11,12}

The figure below show the two separate trees  in the forest.

The first step is to order the nodes of both trees using following formula.

  • If a node has left child, then if comes immediately below the node.
  • If a node has another node in the save level, then it becomes the right child of the node.
  • If a node has right child then, ignore it.

Such a representation of two trees is given below.

Forest with Two Ordered Trees - binary tree concepts
Forest with Two Ordered Trees

Your next step should be to join these two tree into one by connecting their roots. This is because the roots of the trees are at the same level. See the figure below

Forest with Two Ordered Trees Joined - Binary tree concepts
Forest with Two Ordered Trees Joined

The new tree is a binary tree, the node at the save level in above diagram becomes the right child. The final tree structure look like the one in figure below.

Final Joined Binary Tree - Binary Tree Concepts
Final Joined Binary Tree

Total Number of Edges

In a complete binary tree, the total number of edges is given by the formula,

2 (N_L - 1)\hspace{1ex} where \hspace{1ex}N_L\hspace{1ex} is \hspace{1ex}total\hspace{1ex} number \hspace{1ex}of\hspace{1ex} leaf \hspace{1ex}nodes.

For example, see the tree below.

Complete Binary Tree with Edge Labelled -Binary Tree Concepts
Complete Binary Tree with Edge Labelled

In the above diagram, we have N_L = 8.


&= 2( N_L - 1) \\
&= 2 ( 8 - 1) \\
&= 2 (7) \\
&= 14\hspace{1ex} edges.

Height of a Binary Tree

The maximum level of any node of the binary tree is called the height of a binary tree.

For example, see the figure below.

Height Of The Tree - Binary Tree Concepts
Height Of The Tree

In the above tree figure, the maximum level of the tree is 4,

Therefore, the height of the tree is Height(T) = 4.


R.G.Dromey. 2008. How to Solve it by Computer. Pearson Education India.

Robert Kruse, Cl Tondo. n.d. Data Structures and Program Design in C. Pearson Education India.

Thomas H. Cormen, Charles E. Leiserson, Ronald Rivest, Clifford Stein. 2009. Introduction to Algorithms. MIT Press.

Data-structure – Ordered Tree vs Unordered Tree

A binary tree can be ordered or an unordered tree, so what is the difference between these two trees. In this lesson, you will compare the ordered tree vs. unordered tree and tell the difference.

Ordered Tree Example

The name suggests that the ordered tree must be an organized tree in which nodes are in some order. What is the common ordering method?

An Ordered Tree - ordered tree vs. unordered tree
An Ordered Tree

In the figure above, for any node, its left child has less value than the node itself and the right child has a value greater than the node.

Unordered Tree

In a binary tree, when nodes are not in a particular order it is called a unordered tree.

See the root, all the left descendants of the root are less than the root value and all right descendant has a value greater than the root.

Unordered Tree - ordered tree vs. unordered tree
Unordered Tree

This is the primary difference between the ordered tree vs. unordered tree.


R.G.Dromey. 2008. How to Solve it by Computer. Pearson Education India.

Robert Kruse, Cl Tondo. n.d. Data Structures and Program Design in C. Pearson Education India.

Thomas H. Cormen, Charles E. Leiserson, Ronald Rivest, Clifford Stein. 2009. Introduction to Algorithms. MIT Press.