xml
Moderator: General Moderators
Re: xml
Great question!shiznatix wrote:i have seen xml code and whatnot but i dont see what xml can do that html can not do. whats so great about xml anyway?
XML is put simply, a language used for presenting *data*. Nothing else.
In my game, we now have an xml-based schema for our database tables. It looks like this:
Code: Select all
<?xml version="1.0"?>
<schema version="0.3">
<table name="vote">
<field name="vote_id" type="I1">
<autoincrement/>
<key/>
</field>
<field name="vote_text" type="X"></field>
</table>
</schema>You asked what makes it better than html. First and foremost, computer processing. Processing HTML (or more specifically, tag-soup) is hideously complex. Tags aren't matched. Required attributes might not be present. Elements may or may not have endings. Contents may or may not be encoded correctly.
Trying to write an html parser is beyond hard - its nearly impossible, because as soon as you think you have it working, you end up with another page that isn't compliant enough for your parser. Even parsers like Snoopy, built from the ground up with the awareness of tagsoup, have problems with some pages.
Compare with XML. Parsers are so simple for XML that there are now native extensions for it in php5. You can build a tree, pick out specific elements, and you know it will work because xml is required to be valid. Thats the huge difference from html.
On top of that, its better because its faster. "Faster?" You say?
Yes. Imagine a page full of font tags, tables, marquee tags, and other tag soup mess. Then picture in your mind removing EVERYTHING except the data. See the difference? Thats the power of xml v. html for moving raw data. Its faster, its simple, and its amazingly useful.
It powers gmail, google maps, amazon, and dozens of other sites. It is becoming the definitive best solution for moving data on the web.
That cover most of your questions?
Very close - its not a database (although you can store xml in a databse), but it is a source of data. You can choose to make it public, like many sites do (RSS), or it can be private.Grim... wrote:So it's a bit like storing data in a public database and letting anyone get at it and display it how they like, right?
But the last part was dead on: Its data, and what you do with that data is completely up to you.. transform it to xhtml, style it with css, display it, parse it, whatever you like. That is the true power of raw, accessible, parsable data. Its easy to work with.
Have a look at http://www.w3schools.com. Meaby it's not the best, but i usually like their articles...
XML is mainly used for open-sourced projects and RSS. And you can appy CSS to an XML file... W3C's examples do it. http://www.w3schools.com/xml/cd_catalog_with_css.xml