To start my blogging with what ever little I know here is some basic stuff for beginners of XML. I have worked almost more than 4 years with XML and related technologies. It was really a cool stuff I found it to be handy, flexible and standard stuff.
To start with XML I want to tell you something, XML stands for eXtensible Markup Language. As the name indicates it is an open standard that can grow and is defined by markups. Here it comes some common points to remember when you do your XML
- Defining an XML File:XML is a very easy language to use and maintain. There are just a few steps to follow to successfully make an XML file. The first thing to do is do define the document as an XML file. An XML file doesn't have to end in a .xml entension, all it needs is the first line to be
<?xml version="1.0" encoding="UTF-8"?>
- Closing and Opening Tags:It is safe to say that that the line above is the only thing in XML that doesn't need a closing tag. Unlike HTML, every tag you make in the XML file needs an open and closing tag. You can make up any type of a name for the type, as long as you open and close it. This includes any tag you might want to make for images, links, etc. For instance, in the following code, see how the spoono tag is opened and closed?:
- Tags are Case Sensitive:Unlike HTML, XML tags are case-sensitive and defining one doesn't mean the same as the other. For instance, this would give you an error:
- Nesting:Every tag must be inside the root element tag which must encompass all the other sub-elements. This pretty much means that in our script, all the coding we do must be inside the <mytag></mytag> and you can't have multiple instance of the mytag tag. Everything must be nested inside this immense mytag tag. Also, tags must be closed in the reciprocating order as they are open. For example:
<news>I'm writing a tutorial</news>
- Attributes:In any given tag, you're allowed to have as many attributes as you want. To give an example of an attribute, the "href" in the "a" tag of an HTML link is an attribute. So is the "src" in an "image" tag, etc. All the attribute values inside the tag must be in quotes. For example:
<title type="post"><b>mytag Rocks</b></title>
<news author="Reflex Demon" date="23/07/08">I'm writing a tutorial!</news>
As you can see, there aren't too many rules to follow for writing XML code. It is really the parser for XML which has to do the grunt work by reading the XML file and making it look useable to a viewer. If you have any questions, feel free to post on the discussion board by clicking the link below and someone will be sure to help.