<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
    <title>XML | Systematix Articles</title>

    <link>http://www.systematix.co.uk/articles/</link>
    <description></description>
    <dc:language>en-ca</dc:language>
    <dc:creator>james@systematix.co.uk</dc:creator>

    <dc:rights>Copyright 2013</dc:rights>
    <admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />

        
        <item>

          <title>A basic introduction to XML</title>
          <link>http://www.systematix.co.uk/articles/index.php/article/introduction-to-xml</link>
          <guid>http://www.systematix.co.uk/articles/index.php/article/introduction-to-xml</guid>

          <description><![CDATA[
      <p>Welcome to a basic introduction to eXtensible Markup Language (XML). Like a lot of other languages used on the web, XML is a markup language. In fact it is the most flexible markup language around and plays a vital role in many applications not just on the web. For training vist our <a title="XML training courses" href="/xml-training/">XML training courses</a> page.</p>
<p>A markup language is one that uses syntax and text to make data distinguishable and provide structure. In the case of XML it uses elements or tags similar to HTML. These tags are then used to structure the data for the required application.</p>
<p>&nbsp;</p>
<h3>Tags</h3>
<p>Let start by looking at some XML tag and the syntax that comprises them. The first tag you should be come familiar with is the XML declaration tag which tells what ever program is going to be reading your file what it is going to find in it. This must appear as the first line in all XML files.</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;</pre>
<p>This will be the declaration you will use, almost all the time when producing an xml file. This states that we will be writing in XML version 1 following the specification lay down by the W3C and that the character set in use is UTF-8. This is Unicode Transformation Format and is a variable-length character encoding for Unicode. It can represent any character in the Unicode standard, whilst still being backwards compatible with ASCII. For these reasons, it is  becoming the preferred encoding for e-mail, web pages and other applications where characters are stored or streamed.</p>
<p>Now let create some of our own tags.</p>
<h4>Example:</h4>
<pre>&lt;Name&gt;John&lt;/Name&gt;</pre>
<p>The above example shows a single piece of data being formatted into XML tag. There are two main types of tag, an opening and a closing. They both are a word encased in a pair of angle brackets; the close tag is differentiated by the forward slash after the first bracket. This the basic syntax structure of tags.</p>
<p>The word that is inside the tag syntax is the name of what this tag is used for. When naming a tag you should use no special characters, stick to a-z A-Z 0-9 _ -.<span> </span>In XML you can choose any name for your tags in other languages there are restrictions.</p>
<h3>Data</h3>
<p>Now we will look at what can be stored in an XML format and why it fits some applications better than others.</p>
<h4>Example:</h4>
<pre>&lt;Quantity&gt; &gt;50 &amp; &lt;75 &lt;/Quantity&gt;</pre>
<p>If we want to try and use the following tag and data we run in to a problem. There are characters used in the data that have restricted use in XML. The reason is that they are used in the markup schema and to allow language to be read clearly by a parser some additional syntax is required.<span> </span></p>
<p><span> </span>Like in HTML you need to use the correct replacement entity. Here are the key entities in XML</p>
<table style="width: 293px; height: 154px;">
<tbody>
<tr>
<td><strong>Entite</strong></td>
<td><strong>Charator Replaced</strong></td>
</tr>
<tr>
<td>&amp;lt;</td>
<td>Less-than symbol (&lt;)</td>
</tr>
<tr>
<td>&amp;gt;</td>
<td>Greater-than symbol (&gt;)</td>
</tr>
<tr>
<td>&amp;amp;</td>
<td>Ampersand (&amp;)</td>
</tr>
<tr>
<td>&amp;apos;</td>
<td>Apostrophe (&rsquo;)</td>
</tr>
<tr>
<td>&amp;quot;</td>
<td>Double quotation mark (&ldquo;)</td>
</tr>
</tbody>
</table>
<p>So using the example above we would have to replace 3 of the characters with these entities.</p>
<pre>&lt;Quantity&gt;&amp;gt;50 &amp;amp; &amp;lt;75<span>  </span>&lt;/Quantity&gt;</pre>
<p>It is possible to use get the XML parser to ignore a block of text that many contain illegal characters. CDATA or characters data declaration will do this. Using the example above we can stop the parser from erroring by doing the following.</p>
<pre>&lt;Quantity&gt;<strong>&lt;![CDATA[</strong>&gt;50 &amp; &lt;75 <strong>]]&gt;</strong>&lt;/Quantity&gt;</pre>
<p>The text has been placed between &ldquo;<strong>&lt;![CDATA[&ldquo;</strong> and &ldquo;<strong>]]&gt;&rdquo;</strong> there for this will not cause an error with the parser. This is a very useful piece of syntax and gets used frequently.</p>
<h3>Structure</h3>
<p>Putting your data into a useable structure is important to do but very easy. It is done by nesting tags within tags. It is the same as arrays used in nearly all programming languages.</p>
<h4>Example:</h4>
<pre>&lt;Item&gt;
 &lt;Name&gt;T-Shirt&lt;/Name&gt;
 &lt;Price&gt;9.99&lt;/Price&gt;
 &lt;Sizes&gt;
  &lt;Size&gt;Small&lt;/Size&gt;
  &lt;Size&gt;Medium&lt;/Size&gt;
  &lt;Size&gt;Large&lt;/Size&gt;
 &lt;/Sizes&gt;
&lt;/Item&gt;
&lt;Item&gt;
 &lt;Name&gt;Shorts&lt;/Name&gt;
 &lt;Price&gt;14.99&lt;/Price&gt;
 &lt;Sizes&gt;
  &lt;Size&gt;Small&lt;/Size&gt;
  &lt;Size&gt;Medium&lt;/Size&gt;
  &lt;Size&gt;Large&lt;/Size&gt;
 &lt;/Sizes&gt;
&lt;Item&gt;
</pre>
<p>This should provide you with basic understanding of how to create XML pages. There is still a lot more you can do with the XML structure also many ways of utilizing XML.</p>      ]]></description>
      <pubDate>Wed, 18 Nov 2009 18:06:31 +0100</pubDate>
        </item>

        
        
    </channel></rss>