• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML -vs- HTML or others

 
Ranch Hand
Posts: 458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the advantage of XML of other methods.
I'm green as can be in this arena so go easy on the answer.
Yes, Paul this a blatant attempt to win a free book!
However, This is a real question I've had. Not being familiar with web development and soon to be involved in it. It's good to learn the pros and cons fo different approaches.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ray,

HTML and XML are really used for two different purposes, but basically HTML is concerned with *presentation* of information, not the informatin itself. XML is *data* only. Not just the data itself, the tags of XML describe what type of data is contained in the document. For example, if I sent you an HTML file with the following information about the weather:

How would you write code to automatically extract that data for your application? What if my HTML changes so that I no longer use HTML tables to display my data? In XML, I would send you a document something like this:

Now you can load up your XML parser and look for the <city> you are interested in, and extract the <temp>, to maybe display on your web site. If you were using XSL, you might process the whole document and transform it into HTML to make it look like you want. You might even transform it into WML for display on a WAP enabled phone or palm device.
So the quick answer is HTML does nothing more than format a web page for display. XML is data that describes itself. Some refer to it as "portable data".
See ya,
Bill
 
Ray Marsh
Ranch Hand
Posts: 458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks... although the mechanics of it all still eludes me a bit.
If I want to display a web page, I can create a HTML file. How does XML fit. Does it replace HTML or is it used in conjuction or both or neither? I may be talking apples and oranges here. Let me know if I am.
Thanks,
Ray
 
Bill Pearce
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you just want to display a web page, consider XML as a source of the *data* included in the web page. What you would need then, is a way to transform the XML document into HTML. This is where XSL comes in. In order to make the transformation, you need yet another file, an XSL stylesheet (as well as an XSLT processor like Xalan).
The stylesheet is a mixture of XML and HTML tags, and tells the processor how to format certain elements based on the tags surrounding them. For example, lets say you want to take the previous weather XML document and put it on your web page. Your XSL stylesheet might have tags like:

The above (which it just a portion of the actual stylesheet, tells the processor to make the information in the "name" tag bold and the value in the "temp" tag italic.
If you have Xalan installed correctly (have the jar in your CLASSPATH), all you have to do to convert XML to HTML using a stylesheet is (from a command line):
java org.apache.xalan.xslt.Process -in weather.xml -xsl style.xsl -out weatherPage.html
So this allows you to batch-process many XML documents, turning them into static web pages for use on your site. If you then want to totally change the way your site looks, design a new stylesheet, process the docs again, and you're done.
Or if you already have a servlet engine, you can write a simple servlet that calls the processor and dynamically applies a stylesheet based on some variable.
Hope I have not confused you further. You should be able to download Xalan from xml.apache.org and run one of the simple examples.
Good luck,
Bill
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, it is really helpful.
------------------
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
As Bill said XML is "data"specific whereas HTML is "presentation " specific . Being so,XML helps users to easily manipulate the file & search a particular text.It also helps the user in understanding the tags even if the user does not have knowledge of the language which was not possible with HTML.
Hope I helped to show how XML is better than HTML etc.
Regards,
Ira

------------------
 
reply
    Bookmark Topic Watch Topic
  • New Topic