A Short Introduction to the Basics of XML
XML is one of those technologies that have been around for a while, but no one knew what to do with it, until a few years ago. The biggest complaint I’ve ever heard about XML is that most new programmers just don’t know what to do with it.
XML definition: XML (Wikipedia.org)
The Extensible Markup Language (XML) is a W3C-recommended general-purpose markup language for creating special-purpose markup languages, capable of describing many different kinds of data.
If your looking at that definition and thinking to yourself, what does that mean?, then let me explain more.
XML is just a flat file. That is it, nothing more to it. Your program will run through the XML document just like a normal flat file, but much easier to read. The data is split up into tags, much like the tags used in HTML. Parses that pull out the information look for these tags and will pull out the information that is in between a start and end tag.
Example:
Data in delimited format (using a pipe to be exact):
Joe Smith|3 Mill Road|Dover, NJ|07833|5705550055
XML version:
Joe Smith
3 Mill Road
Dover, NJ
07833
5705550055
It’s the XML version much easier to read and understand? If I were to leave this project to the side for a long period of time, delimited data would have no meaning unless I had some short of reference. With the XML, I can immediately determine what each data field represents.
XML is good for two main reasons:
1. Easy to parse through.
When making a flat file, usually most programmers will delimit a flat file by either using a comma, tab, pipe |, ect. This works well for the most part, but as a programmer you will run into problems trying to keep data integrity intact. There will be a time that your output will be not 100% perfect. By using a XML document, this can be significantly reduced.
2. Standardized format, making it easy for integration into multiple programming environments. This also allows for other programmers to quickly understand your program.
What are some possible applications of an XML document?
1. An excellent way for two different programming environments to communicate between each other
2. Data transfers between web applications. XML is utilized in standards such as SOAP and popular with building Web 2.0 applications (AJAX). It is much easier to parse through a XML document, then a HTML web page.
3. XML documents can be used for Flash applications, while also allowing for a a text version to be avaliable for SEO purposes.
Stay tuned for an article on how to read and write XML documents with PHP.
One Response to “A Short Introduction to the Basics of XML”
Trackbacks