What is xml why when should we use it
What is xml why when what were should we use it.
Can we have that good explenation you did about the .net post??
XML is merely a way of encoding data as text using markup. Say you want to keep track of some books, you could encode that data as:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<title>Dilvish, the Damned</title>
Looks a lot like HTML, except the tags are not HTML tags. I just made the tags up as I needed them.
Now how can you use that info? Well, I can move it around just by sending you the text. I can parse it and get the pieces. Think of it much the same way that you would think of a database, except that it is a lot simpler and non-proprietary.
One thing I can do is apply an XSLT (eXtensible Style Language Transformation) style sheet to it. Think of XSLT as a simple scripting language. The script, though, is written as XML (this starts getting recursive after a while!). For example:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<li><xsl:value-of select="author"/>: <xsl:value-of select="title"/></li>
The output of the transformation is:
- Jack Vance: Lost Moons
- Jack Vance: Cugel Saga
- Roger Zelazny: Dilvish, the Damned
Now how you do that applying depends on what environment you are developing under.
Another way to work with it is to use the Document Object Model (DOM) to walk through the nodes. You need a parser, but the interface to the parser is a W3 spec, found here: [w3.org...]
There are also other different parsers.
So XML is just marked up data. The question is what do you want to do with the data? I tend to use XML in many places that I would formerly have used a database as it is easier to write and maintain.
I'm new to the concepts of XML: so is that completely cross-browser friendly?
Meaning the now-dreaded NN4 - can it parse XML?
Also: are there any HTML to XML programs out there (I mean, I get that you need to mark the data up, but anything that would take the basic HTML and make it lower case, etc.)
Finally: can you use XML for things like navigation menu includes?
If you do your processing on the Server Side, only HTML is delivered to the client. So as long as your HTML works in Netscape, you have no problem. IE starting with version 4 has client side support, and I think Netscape 6 does too, but client-side XML will always be proprietary until the W3C adds extensions to the XHTML spec. I recommend server-side processing.
As far as converting HTML to XHTML, there is a program called HTML Tidy available on the W3 web site that will do it for you. Available from here: [w3.org ]. XHTML is HTML coded to the XML rules. Questions about it should be posted in the HTML forum.
XML is just data. So what you use it for and how you use it is up to you. It doesn't implicitly do menus.
Great info, Xoc, many thanks.
Server-side processing: what do you use? Are there ASP, CFM, and PHP "tags" that would do it? Is that what you mean?
Or are you talking about some specific programs that sit in a CGI-bin, etc?
Thanks alot for this info :)
See this post for an example of how you'd apply XSLT to XML on an Active Server Page: [webmasterworld.com...]
For other environments, you'd need a different parser and different scripting code. Depends on the environment on how that would work. But the basic scheme is the same. You get the XML, you get the XSL, you apply one to the other producing HTML, you send the HTML to the client.