|
|
|
eXtensible Markup Language (XML)
What is XML?
What Does XML Do?
Why use XML?
GetData and XML?
|
| What is XML?
|
|
XML stands for eXtensible Markup Language and is used to structure, store and send
information. XML looks similar to Hypertext Markup Language (HTML) in that its syntax
uses begin and end tags to define data. HTML offers a universal method to create web
user interfaces whereas XML offers a universal way to describe and work with data.
Software developers create their own XML structures and define their own tags that
describe their particular data. XML can be used to communicate with other systems
that understand XML regardless of platform, operating system, language or data store
differences between the two systems.
All XML tags must have a start tag and an end tag (called elements). XML start
tags are identified within “<” and “>” characters and XML end tags are
identified within “</” and “>” characters.
Figure 1: Example XML Tag
The XML shown in figure 1 shows an empty tag, that is, a tag that contains no data. Sometimes an empty tag is
expressed as shown in figure 2.
Figure 2: Empty XML Tag
An XML tag is case sensitive thus <Name> and </name> would be invalid XML.
The data for the name tag is stored
in between the start and end tag as shown in figure 3.
|
<name>Bart Simpson</name>
|
Figure 3: <name> Tag with Data
An XML tag can be nested within other XML tags. Figure 4 shows an example of nested XML tags. This nesting
demonstrates a parent child relationship. Figure 4 shows that a person has a name and a hometown. Nested XML
tags must be nested properly, that is the child tags must be closed before the parent tags. In figure 4 the <name>
and <hometown> tags are closed before the <person> tag.
<person>
<name>Bart Simpson</name>
<hometown>Springfield</hometown>
</person>
|
Figure 4: Nested XML Tags
An XML document must have a root tag. Although figure 4 is a valid complete XML document we could not add more person
records to it. Figure 5 shows the use of a root node named <people>.
<people>
<person>
<name>Bart Simpson</name>
<hometown>Springfield</hometown>
</person>
<person>
<name>Lisa Simpson</name>
<hometown>Springfield</hometown>
</person>
<person>
<name>Chief Wiggum</name>
<hometown>Springfield</hometown>
</person>
<people>
|
Figure 5: Root XML Tag
|
|
| What Does XML Do?
|
It is important to remember that XML does not do anything. XML is simply used to structure, store and send information.
<note>
<to>Homer</to>
<from>Marge</from>
<subject>Reminder</subject>
<body>Don't forget this weekend!</body>
</note>
|
Figure 6: Message XML
Figure 6 shows a note from Marge to Homer stored as XML. The note has a sender, stored in the <from> tag,
and a receiver, stored in the <to> tag. The note also has a subject, stored in the <subject> tag and a body,
stored in the <body> tag. This text is pure information wrapped in XML tags. Software must be developed to
use this information. In this example, software must be developed to send, receive and display the note from
Marge to Homer.
|
|
| Why Use XML?
|
XML offers a number of benefits that have caused it to be widely adopted
as a data representation format.
- Simplicity
XML is very simple to understand and is easily readable by a human. XML is self-describing as an XML document
contains both data and a description of that data. As XML is a text-based format a person can read and edit
XML using standard text editing software.
- Flexibility
As XML is not confined to a fixed structure, a developer can define a structure specifically designed for
the problem in question. Furthermore applications that use XML are more resistant to additive changes to
the structure of the XML. For example, an application would not break if a new tag is added. This flexibility
is uncommon in other data formats.
- Interoperability
XML can be used to interoperate with any other system that understands XML. Using XML means a developer does
not have to worry about platform, operating system and language differences between systems.
|
|
| GetData and XML
|
|
GetData requires a customer to generate an XML request message. This XML request message contains details about
the customer, such as a username and password, and details about the request, such as the company to retrieve
credit information on. GetData returns an XML response message containing the data requested by the customer.
|
|
|
|
|
|