Monday 15 January 2018

How to include the reference of multiple namespaces in an XML Document

An XML element can contain the reference of multiple namespaces. Now here we create an XML document named multiplenamespaces.xml to learn how to include the reference of multiple namespaces in an XML document.

/////Shows the code of the multiplenamespaces.xml file/////

<?xml version="1.0"?>
<Song xmlns="http://www.namespace.com/Song"
xmlns:art="http://www.webucator.com/Artist">
<Title>The Girl Is Mine</Title>
<Year>1983</Year>
<Artists>


<art:Artist BirthYear="1955">
<art:Name>
<art:Title>Mr.</art:Title>
<art:FirstName>Anil</art:FirstName>
<art:LastName>singh</art:LastName>
</art:Name>
</art:Artist>

<art:Artist BirthYear="1942">
<art:Name>
<art:Title>Mr.</art:Title>
<art:FirstName>Mohit</art:FirstName>
<art:LastName>Sharma</art:LastName>
</art:Name>
</art:Artist>

</Artists>

</Song>

In this we have created an XML document that contains the Song element. This element uses two namespaces, http://www.namespace.com/Song and http://www.webucator.com/Artist.
The http://www.namespace.com/Song namespace is the default namespace while the http://www.webucator.com/Artist namespace is specified with the help of the art prefix. The default namespace is referred by the child elements, Title, Year, and Artists, of the Song element. However the child elements of the Artists element including ArtistBirthYear and Name refer to the art prefix.

The output of the multiplenamespaces.xml file.



2 comments:

  1. I visit daily some blogs and information sites to read posts, but this webpage presents feature based writing. Thanks to you for providing amazing Information. Please keep us informed like this. Thanks for sharing.

    Nintendo Wii U Emulator
    Best Email Marketing Software

    ReplyDelete
  2. Thank you sir for visiting my blog

    ReplyDelete