I'm learning it! More specifically XSLT, though.
Does anyone else here know XML? It's probably the easiest to learn markup language out there! But it's really useful .
Here's an example of some code I typed up this morning (with the XSLT code):
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="testing.xsl"?> <Collection> <Game> <Title>Legend of Zelda</Title> <Genre>Adventure</Genre> <Year>1986</Year> <Rating>E10</Rating> </Game> <Game> <Title>Super Mario Bros.</Title> <Genre>Platforming</Genre> <Year>1985</Year> <Rating>E</Rating> </Game> <Game> <Title>Minecraft</Title> <Genre>Indie</Genre> <Year>2011</Year> <Rating>NA</Rating> </Game> </Collection>
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h1>My game collection</h1> <table border="2"> <tr> <th>Title</th> <th>Genre</th> <th>Release Date</th> <th>ESRB Rating</th> </tr> <xsl:for-each select="Collection/Game"> <tr> <td><xsl:value-of select="Title" /></td> <td><xsl:value-of select="Genre" /></td> <td><xsl:value-of select="Year" /></td> <td><xsl:value-of select="Rating" /></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
SImplistic, I know, but I'm still learning!
Offline
veggieman001 wrote:
I don't get why I'd use it.
XML is great for creating databases, and XSL is used to display them.
Offline
throughthefire wrote:
veggieman001 wrote:
I don't get why I'd use it.
XML is great for creating databases, and XSL is used to display them.
Oh. Why not just use PHP and MySQL?
Offline
veggieman001 wrote:
throughthefire wrote:
veggieman001 wrote:
I don't get why I'd use it.
XML is great for creating databases, and XSL is used to display them.
Oh. Why not just use PHP and MySQL?
Meh. XML is simpler.
Offline
throughthefire wrote:
veggieman001 wrote:
throughthefire wrote:
XML is great for creating databases, and XSL is used to display them.Oh. Why not just use PHP and MySQL?
Meh. XML is simpler.
But how do you use in in a web page? Can you actively update it?
Offline
veggieman001 wrote:
throughthefire wrote:
veggieman001 wrote:
Oh. Why not just use PHP and MySQL?Meh. XML is simpler.
But how do you use in in a web page? Can you actively update it?
You create the database, then write a style sheet to tell the browser how to display it.
Offline
throughthefire wrote:
veggieman001 wrote:
throughthefire wrote:
Meh. XML is simpler.But how do you use in in a web page? Can you actively update it?
You create the database, then write a style sheet to tell the browser how to display it.
But can you actively change the database from page input?
Offline
veggieman001 wrote:
I don't get why I'd use it.
XML is used for storing information in a computer & reader friendly form its close to both
consider a .dat file in C++ generally it will look like thrash , same with a pdf [if u dont trust me open a pdf inside notepad and try reading) . On the other hand XML offers data to be stored like
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="testing.xsl"?> <Collection> <Game> <Title>Legend of Zelda</Title> <Genre>Adventure</Genre> <Year>1986</Year> <Rating>E10</Rating> </Game> <Game> <Title>Super Mario Bros.</Title> <Genre>Platforming</Genre> <Year>1985</Year> <Rating>E</Rating> </Game> <Game> <Title>Minecraft</Title> <Genre>Indie</Genre> <Year>2011</Year> <Rating>NA</Rating> </Game> </Collection>
Now very simply you can understand this part of code
The above example shows a <Collection>,
this collection contains many <game>s
each game has some properties say <title>,<Genre>,<Year>,<Rating>.
you can see the difference youself how much xml helps you in keeping the saved file user friendly , it allows you to work on cross language applications say ur server generates an xml file which your client reads . [ this xml file saves you a lot of client side processing as xml parser are native in all browsers ]. Or say you want to make some common file which many programs on your computer will read so there two ways
1 -> Write a class and load the data in class everytime and this class will be very hard to change [as a small change in a single program will make u bind to re-write all programs that read the file].
2 -> Write an XML file and use an xmlparser now no program will messup if you change the data structure as if it dosnt understands what a tag means it will just ignore it .
---
XML is also helpful when your program has continous feature addition [and this program takes feed from server], now version 0.1 wont understand version 0.6's uber new features but it should atleast display some information . here xml plays a very important role , likewise the last example the <tag> it dosnt understand will be ignored by the version of client and hence it wont mess things up.
Now makes sense why to use xml [ or JSON or something similar]
makes sense now ?
Offline