The ecosystem around XML grew at a blistering pace. It looked as if the entire OOP world had conspired to make a point against the poor relational database.

The most useful tool turned out to be XPath. It is based on the idea of an operating system's absolute path notation. In fact, there are a lot of similarities between a file system and an XML document. Both follow the inverted tree data model.

The file system looks like this:

And an XML doc:

The absolute path of the folder Custom64 is: "C:WindowsapppatchCustomCustom64"

Similarly, XPath for the element institution is: /employeeRecord/educations/education/institution

XPath addressing scheme is useful when you are exchanging information about a particular element. You can exactly pin-point which element you are referring to. This is great for written communication.

But the real purpose of XPath is to serve as a query language.

The expression mentioned above can be tweaked a bit to get the names of the institutions the employee has been to.


That expression yields the following:

Rockdale HIgh School

Princeton University

You want to know what was the starting designation of John Doe's previous job? This XPath expression will give you the exact answer:


The evaluation output in this case is: Software Engineer.

Imagine expecting such a cool query tool for a CSV file! Unless you load that on to a database table you just cannot do anything with that dumb piece of text.

As if XPath was not enough, the XML management group came up with another language called XQuery. That was a direct challenge to SQL. The syntax was on those lines.

Here is an example based on the same XML file:

for $x in /employeeRecord/educations/education

where $x/accomplishment="Computer Science Major"

return $x/graduation_yr

In plain English, the above code means: Find the graduation year of John Doe for Computer Science Major.

XQuery has the elegance of SQL and is used in complex cases. Sometimes, it packs more punch than SQL. for example, if you have to put a condition on a lower level node and return from a higher level node. SQL demands joins, which become quite clumsy to handle.