aspose file tools*
The moose likes XML and Related Technologies and the fly likes XML, HTML, what's the difference? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML, HTML, what Watch "XML, HTML, what New topic
Author

XML, HTML, what's the difference?

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1199
I'm doin' the cattle drive, and I am currently workin' on Servlets, which generate web pages using HTML. I have a RUDIMENTARY grasp of HTML, and I am assuming that XML is similar. How are they different, and where can I find a good source of info on XML?
YanNaing WTint
Ranch Hand

Joined: Oct 30, 2001
Posts: 40
Hi buddy,
For my suggestion, pls go to http://www.w3schools.com/.
Good Luck.


Yan Naing Wynn Tint (SCJP2, SCWCD)
Alagan Devika
Greenhorn

Joined: Jan 04, 2002
Posts: 17
Hi,
This url is a best suggestion for begginers of XML.
Thanks
Shanthi
Jing Teng
Greenhorn

Joined: Nov 15, 2001
Posts: 11
Yes, http://www.w3schools.com/ is a good place for beginners.


=================================<br />SCJP2,SCWCD
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
I have a RUDIMENTARY grasp of HTML, and I am assuming that XML is similar. How are they different, and where can I find a good source of info on XML?

The link above is a good one, but I'll try to do a brief explanation of how the two are similar and different.
First of all, XML looks a lot like HTML. You use tags which can have multiple attributes. The basic difference is the meaning of the tags. In HTML, the tags give extra information about how data should be displayed. In XML, the tags give extra information about what the data represents.
For example, you might have a block of code that looks like this in HTML:

And you might have a block of code that looks like this in XML:

Notice that the tags in the HTML code block say how the text should be displayed - the first line should be displayed in bold and the second line should be displayed in italics. There is nothing there, however, that let's you know what the data really represents.
In the XML block, you can easily see that the data represents a first and last name pair (in this case, mine). However, there is no information about how to display the data - that's left out in XML. In XML, the markup is there in order to describe what the data is, not how to display it.
One other key feature is that, unlike in HTML, you can create create your own tags in XML. If you're working on an address book, you might find a "CITY" tag useful. If you're working on a astronomical catalog, you might find a "STAR" tag useful. You can use whatever tags you need in order to accomplish the task at hand, because each tag really just explains what the encapsulated text means.
Now, this is a very brief overview of the differences between HTML and XML. There are many more differences and similarities. I'm just hoping this will help you understand the purpose of XML.
Corey


SCJP Tipline, etc.
Scott Bain
Ranch Hand

Joined: Dec 21, 2001
Posts: 46
Differences between HTML and XML include:
All tags in XML must be closed, either by a matching, closing tag:
<B>Hello</B>
Or by a self-closing tag:
<BR/>
Singleton, or atomic tags, which are allowed in HTML (like <P> are not allowed in XML.
Also, elements cannot overlap in XML. In HTML the following would be perfectly acceptable:
<b><i>Hello</b></i>
Where the closing tags are not precisely in the reverse order of the openeing tags, but in XML this would not be allowed. You must do this:
<b><i>Hello</i></b>
You may have also noticed that attribute values in HTML may be in quotes, but that this is not necessary. In XML, attribute values must ALWAYS be in quotes.
There is a new version of HTML coming out, which conforms to all the rules of XML, and therefore "is" XML as well at being a specific langugage for web pages. It's called XHTML, and you can find a nice tutorial at:
http://www.wdvl.com/Authoring/Languages/XML/XHTML/
(I also agree with those who've recommended the w3schools site. Very nicely done).
-Scott Bain-
www.netobjectives.com


Scott Bain<br />Senior Consultant<br />Net Objectives<br />425-591-5844<br /><a href="http://www.netobjectives.com" target="_blank" rel="nofollow">Net Objectives</a><br />----------------------------<br />* Sign up for our free newsletter by sending an e-mail to<br />info@netobjectives.com<br />* Learn about and join our design pattern community of practice by going to<br /><a href="http://www.netobjectives.com/dpexplained" target="_blank" rel="nofollow">www.netobjectives.com/dpexplained</a><br />* Alan Shalloway & Jim Trott's - Design Patterns Explained: A New Perspective on<br />Object-Oriented Design is now available<br />* Our new CDROM-based XML training is now available as well
Meera Chandrasekaran
Greenhorn

Joined: Jan 08, 2002
Posts: 10
They are very much different semantically rather than the syntax.
While HTML is represent presentation on the browser, XML is more of a document exchange format that adds meaning to content rather than just represent a view.
The essentials at www.xml.com are good.
The book "Inside XML" is very good too.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1199
Thanks guys! Your posts have been a great help.
See ya around the ranch!
Raju Malik
Greenhorn

Joined: Jul 30, 2001
Posts: 6
Here I come learning to you people and sites now, you suggested. thanks,
Raju


Gayatri mantra gives us wisdom. "us" means all of us.
Doug Wang
Ranch Hand

Joined: Oct 05, 2001
Posts: 445
Always use the HTML Tidy to clean up your html pages. Also in this page Raggett explains the diference between HTML and XML (here refer to XHTML) very clearly.

Doug


Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
The shortest explanation I read until now is:
In HTML <table> is possible, but <chair> not.
In XML both is possible.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Axel Janssen:
The shortest explanation I read until now is:
In HTML <table> is possible, but <chair> not.
In XML both is possible.

Don't get the tags in the two languages mixed up. In HTML, all tags refer to display properties. In XML, all tags refer to data properties.
For example, in HTML, the table tag refers to a graphical representation of a table, or grid on the page. In XML, a chair tag most likely refers to a real, physical chair. Within that chair tag, you'd probably find attributes such as height, number of legs, etc. These attributes describe the chair. The HTML table has nothing to do with a real life table that you might eat a meal at.
Notice that, when talking about the HTML table tag, I can say definitively what it is. That's because the table tag (like all HTML tags) is predefined. In XML, however, you can use whatever tags that best fit your data model. If you're describing furniture, you might have a chair tag or a table tag. If you're describing a person, you might have a name tag or a social security number tag. That's why, when I talk about the chair tag, I say that it will "probably" contain this or "might" contain that. I can create a chair tag that is entirely different from someone else's chair tag in XML. In HTML, however, everyone's table tags will be the same (have the same attributes, anyway).
The real key to the difference between XML and HTML isn't that you can have different tags, but it's the difference in the meaning of the tags. In HTML, markup describes how the enclosed data should be displayed. In XML, the markup explains what the data is, not how it should be displayed.
Corey
Scott Bain
Ranch Hand

Joined: Dec 21, 2001
Posts: 46
Another way to state the distinction:
HTML is a language. It has semantics and grammar, and a specific purpose (presentation)
XML is a meta-language. You can define other languages in it, by creating specific semantics and grammar (often expressed in a DTD or Schema). One such language is XHTML, another is XSLT, another is XML-Schema. All languages written in XML must conform to the rules of well-formedness (which traditional HTML does not).
-S-
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML, HTML, what's the difference?