Let’s start with XML Map.
With our preferred text editor, let’s create a blank file and add XML header information.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Each XML file must contain a root element. In our tutorial, we want to create an XML containing business cards so we will add a business cards root element.
<businesscards> … </businesscards>
Writing an XML element is quite simple; we only have to keep in mind some simple rules so our XML will be valid:
- Each element consists of an opening tag (<businesscards>) and a closing tag (</businesscards>).
- Each tag in an XML file must be enclosed by an opening angle bracket “<” and a closing angle bracket “>”; the tag name is inside these two characters. To define a closing tag, we have to add a slash “/” character after the opening angle bracket.
Tag names must be formatted respecting some simple rules:
- They cannot start with a number.
- They cannot start with a dot (.), comma (,) character, or any other punctuation characters. Names cannot start with “xml” word in any format such as uppercase, lowercase, etc.
- They cannot contain spaces
Above we have listed only some of the many XML specifications and for this tutorial, we do not need anything else.
Let’s continue this tutorial by adding a card element inside our root element.
<businesscards>
<card> … </card>
</businesscards>
Now inside our card let’s add all the card elements in the Excel table: name, jobtitle, address, phone, mail, and inside each element we add a sample text data.
<card>
<name>Employee name</name>
<address>Employee address</address>
<phone>999-999999</phone>
<mail>employee@mail.com</mail>
</card>
To have a correct map, we must have twice the card elements, so we duplicate this card element and after that XML file looks like this
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<businesscards>
<card>
<name>Employee name</name>
<jobtitle>Job Title</jobtitle>
<address>Employee address</address>
<phone>999-999999</phone>
<mail>employee@mail.com</mail>
</card>
<card>
<name>Employee name</name>
<jobtitle>Job Title</jobtitle>
<address>Employee address</address>
<phone>999-999999</phone>
<mail>employee@mail.com</mail>
</card>
</businesscards>
Save and close it and open the Excel file with the business cards table.