XML Tutorial #6 : xml namespace

Hey welcome back again … in this tutorial i will discuss about xml namespace .. As you know xml offer you to create your own elements or tags whatever you say .. so for this during the time you create a lot of element in lot of xml files a confliction between the elements name easily occur .. To remove this confliction xml also offer you to define namespaces ..

Lets see an example …

<bookstore>

                <title>Famous Freak</title>

                <price>555</price>

</bookstore>

 

<magician>

                <title>The mind freak</title>

                <name>Cris Angel</name>

</magician>

Now you have this two xml files and Suppose somehow you have combine this two xml files … when you do this an error will show up to you because magician and bookstore element both contain a descendant named title ..

Let see how can we fix the error ..

<b:bookstore xmlns:b =“http://www.website-name.com/page”>

                <b:title>Famous Freak</b:title>

                <b:price>555</b:price>

</b:bookstore>

 

<m:magician  xmlns:m =“http://www.website-name.com/page”>

                <m:title>The mind freak</m:title>

                <m:name>Cris Angel</m:name>

</m:magician>

In this code we use an attributes call xmlns that means xml name spaces which is in short form xmlns …

This is how we can fix such types of error using xml namespaces ..

Advertisements
By kfelahi Posted in XML

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s