tags:

views:

774

answers:

17

First, the obvious answers:

  1. XML is a part of one of my data-oriented classes for my Computer Science degree. As of right now we're just messing around with the Internet and learning meaningless stuff we all knew years before we came to university, but the work will definitely pick up sometime soon and I'd like to be well-prepared.
  2. I used to design and develop websites on a freelance basis, so when it comes to things like semantic mark-up, XHTML and the inner-workings of the Internet I know more than enough to get me through an undergraduate course. However, XML seems to be pretty hyped-up so I'm guessing there are a number of different applications for it, including for normal desktop applications as well as purely online.
  3. I wouldn't say that my command of databases is phenomenal, but I know my way around MySQL and Oracle. I know that XML can be used as some sort of database so I'd like to learn more about that.

Now, I've spent the past 3-5 years crawling through web development forums like SitePoint, and now and again I'd come across XML. In essence it seems almost too simple, although I've never found a real need to actually pick it up and learn it. In all honesty (even though I know I'm most-definitely wrong) I cannot see how learning XML would benefit me as a programmer. I've noticed its use in log files for programs like Windows Live Messenger and I've noticed a few Linux fanboy lecturers creating lecture slides as web pages with XML (nothing funnier than watching the Internet crash and their lectures grind to a halt) but I'm still yet to see how it could be useful.

So please, enlightened users of this website, direct me to some reasons as to why I, an undergraduate Computer Science student and budding developer should learn and use XML. Perhaps there are some magical reasons for using it on websites that I've never noticed whilst using PHP, ASP and MySQL, or perhaps there are loads of neat things about using it with Java. If I'm going to learn XML I want to go pretty deep into it, so don't spare all the gory details, acronyms and resources.

As a quick note, there is already a question titled What is the best guide to learn XML, so I've already got those resources.

EDIT: Thanks for the answers. It's all starting to get a bit clearer now, however, many of you are using acronyms for other correlating parts of XML, and whilst it's great that you're mentioning them it would be great to include what these other parts of XML are and why they are useful as well. Also, a lot of the uses that have been provided provide data-storage means. Why not just use SQL?

A: 

XML is just as simple as you think it is. You can use it to send data to and from a server using buzzword acronym AJAX or just store data in it as the latest versions of Office does as well as iTunes among others.

svinto
+1  A: 

XML is widely used throughout the field today. As a developer you can hardly avoid it. Many of your favourite tools will use it for configurations.

MS OOXML stores word and excel and other office files in an xml format. You can write a program that manipulates these files in xml and create some pretty amazing user applications.

XML is easy. It was designed to be easy. It isn't just a markup language. Its more of a specification for markup languages. Now you have hundreds of XML languages like SVG, CML, etc etc.

If you do not know XML you will soon hit a point that you cannot cross if you plan to work in the business environment.

Vincent Ramdhanie
A: 

XML is a great file format for moving data around that any program could read easily. Its also incredibly flexible allowing you to detail any type of data you might need to.

If you want to do anything revolving the web (xhtml, rss, atom, opml, xmlrpc/soap) you might want to study xml pretty hard :)

RaySl
A: 

While XML is not useful in all cases and, like most new technologies, was overused in the beginning, there are many valid uses. Here is a short list of the most common uses.

Eric Weilnau
+1  A: 

XML really is simple. It's worth learning the different approaches to storing data in XML format (eg. elements vs attributes) and when you might want to use one or another.

Another useful thing to understand about XML is namespaces. They're also pretty straightforward once you get it, but the first time you see something like:

<foo xmlns:bar="urn://bar.com/bar">
   <bar:baz>quux</bar:baz>
</foo>

you'll be way further ahead if you already know what that means.

Greg Hewgill
+16  A: 

It's not so much about learning XML, since it really is quite basic by itself, but about learning the technologies around it.

Just take a look at the W3Schools website to see the list of other technologies that float around XML: XSLT, XSL-FO, XPath, XQuery, XLink, XPointer, Schema, XForms. With a good understanding of how XML works (which isn't hard), and solid knowledge of some of these technologies, you can actually create some pretty useful stuff.

nickf
A: 

With knowledge of XML, you will be one step closer to being able to program...

Microsoft's implementation of the Advanced Content interactivity layer in HD DVD

Oh... wait a minute...

Jason
+1  A: 

One area where knowledge of XML has helped me is in parsing the results from REST requests I get from web services like Amazon and Google. Having a somewhat common, hierarchical format made it really easy to navigate to the data I was interested in, and ignore the rest. The same certainly would have been possible with just about any standardized data format, but the current state of technology is that XML is what most of us have standardized on.

Another example of when XML has come in handy was in document translation. At my last job we had to convert between several document formats. Having one standard type that we could transform to and from (XML) cut down on the number of transformations that we had to write. Again, we could have picked any intermediate data format, but there has been so much development around XML that we were able to easily leverage a lot of code that was already written.

In summary, there's nothing inherently special about XML itself. The benefit you get from learning it is that you get to use something that a lot of other developers are already familiar with, and have already written libraries of code for handling.

Bill the Lizard
+4  A: 

Essentially you need to ask yourself what does XML allow me to do?

As you probably know XML by itself does.. absolutely nothing... it's just plain text. the beauty of it is that due to it's nature (and also existing tools/libraries) it excels as a storage/interchange format for an enormous variety of data: general purpose application configuration/log files, database records, you name it.

In theory XML allows:

  • data to flow between subsystems that don't really care about the full document format, but instead expect certain "fields" (tags) to be present.
  • easier data exchange with/by 3rd-party applications (it's easier to get data out of a XML document than to know and parse a custom file format)

To be honest, XML is over-hyped, and in many cases other formats are much more suited (like JSON in most ajax-enabled web apps)

Finally, learning xml is as simple as writing "<tag>some text and </tag>"... The tricky part is learning the tools you may need to use to parse it.

jcinacio
There's a bit more to learning it than that... proper escaping, namespaces, DTDs...
rmeador
schema files, XPaths, standards...
tloach
+1  A: 

Sometimes it's not about learning XML, but about learning how a certain application or business uses it. XML itself is pretty straightforward. Like other markup there are many small details, but in general it's easy to understand what XML is for.

Some areas that it would be useful to know about XML:

  • BizTalk server uses XML, XSD and XSL heavily.
  • Windows Communication Foundation uses XML heavily.
  • XML and XSL is powerful in that you can build an entire web site layout using them together. I've seen sites that are only .xml pages (no .html pages).
  • If you do any server side programming or anything where you need to share data with another system XML is one of the obvious choices to use.
metanaito
+6  A: 

XML gets used a lot, in all sorts of different places - arguably the majority of usages of XML (config files being my pet horrible misuse) are just the result of it being the default method of storing structured data, and are actually misuages where another document format would have been more appropriate. Jeff Atwood has a post called XML: The Angle Bracket Tax that talks to this and there are many other posts on the interwebs making the same sort of point.

That said, in certain fields XML is the standard, and for some good reasons.

One place where you will cetainly hit XML is any sort of integration work - this is a lot of what I do, primarily working with WCF and with BizTalk and I'm working with XML most every day.

SOAP (Simple Object Access Protocol), one of the primary protocols for Web Services, relies heavily on XML, and in BizTalk Server pretty much every message is translated to an XML representation to be handled by the internal BizTalk engine.

That sort of speaks to some of the strengths of XML, it is a comparitively mature format for expressing structured data that has good tool support from multiple vendors. There are lots of additional technologies focused around XML like XPath (which lets you address parts of an XML document) and XSLT (which transforms XML documents) that allow for some very powerful usages. BizTalk mapping from one document schema to another uses XSLT, BizTalk document validation is based on xsd schemas.

Also, if you send a well structured XML document to someone you can be pretty sure they will be able to parse it using standard tools.

It is well worth learning the basics of XML (XSLT, xsd...) as you are sure to encounter it and will want to be at least familiar with it. It really does depend on what you are working on whether you need to go any deeper -

Integration work with heavy use of SOAP and document translation? Probably worthwhile.
Web 2.0 applications? Much better technologies like JSON to invest time into.

David Hall
A: 

It is used soooo much it pays to know XML so you understand it's limitations.

XML is like violence. If it doesn't solve your problem, you're not using enough of it. - attribution unknown

Nat
A: 

XML is a powerful format, but probably too complex for most applications. I wouldn't recommend learning it as an end goal. Learning a new programing language or style will be much more rewarding.

Kozyarchuk
I agree. As of right now I still see no need to learn XML. Sadly, it's part of one of my modules on my Computer Science degree, so in a way I'm forced to use it in the most meaningless way possible.
EnderMB
A: 

I never saw the point of using XML, until I had to work with some code doing XPath queries on XML documents.

Using XML is mostly useful when you need to get information from systems you do not have control over. For your own data, you're probably querying SQL databases. For data in other systems, you probably can export it as XML in some way, or run queries against some webservice or other API to give you data in XML. Now that you have that data, it will never be in the format you need it, with XPath you can basically query that data in a similar way to querying your database with SQL, to get the bits of data you need and ignore everything else.

If your output also needs to be XML, then you use an XSL stylesheet to transform the input into output. But XPath queries are useful even outside a stylesheet.

To get started, I would recommend opening an XML document in Firefox, and use the XPath Checker add on to try and get some data out of that document.

warpr
+1  A: 

The way most people use XML is utterly unhelpful. Structured is structured and when it comes down to it, a structure like separating your data items with commas is a lot more lightweight than XML and possesses the same level of inherent meaning to your program.

The usefulness of XML isn't in the human readable markup. If you're writing out any XML by hand then You're Doing It Wrong (TM).

The usefulness of XML is in the validation methods (of which there are many) that extend from having unambiguous schemas. You can then use those schemas to automatically verify the soundness of any document which claims to follow a given schema.

Let me say it again: if you're using XML and you're not doing automated schema-based validation to find malformed documents then you're better off using comma separated files. You can map the values just as easily and there's less overhead.

Every other advantage of using XML comes from everyone agreeing to use XML in the same manner; that's social engineering, not technical superiority.

Associating values with a text pattern is old as dirt. That's what a lexer does. How fresh and new are C compilers? The part of XML that's the bee's knees is automated malformation detection.

Jason L
A: 

XML is simple, and the W3Schools tutorials are a very good resource. What I found is hat it is not XML that is the hardest or most important, but the accompanying technologies such as XPath and XSLT, which provide a more powerful interface to XML. XPath is especially useful, as if you have ever needed o scrape daa fro other websies, you'll wish you can use XPath on an HTML document. (N.B.: Hml Agility Pack [on Codeplex] let's you do just this on C#)

Also, XML can be used as a Data Source in Java, .NE and similar environments, and can even be used o make games! ([Fuzz] - a now defunct project written by the people at Linux Format - the best linux mag in the UK!)

P.S. I apologise for any missing letter 't's, as my keyboard is broken.

+2  A: 

You can create a document for say 2 orders like this:

<Order ID="100" Date="2008-11-08" ClientCode="10">
  <Item Code="1234" Quantity="5" />
  <Item Code="2345" Quantity="4" />
</Order>
<Order ID="101" Date="2008-11-08" ClientCode="12">
  <Item Code="2343" Quantity="4" />
  <Item Code="1223" Quantity="8" />
</Order>

It is much easier to create and process programmatically this kind of information than, for example, a delimited text file. One of the best advantages of XML, is that the data can be stored hierarchical.

A second very important advantage is that the data can be validated. You can validate for example that the attributes exist, that the Date attribute is a valid date and that the Quantity is numeric.