views:

72

answers:

4

What are the main purpose of using XML in Web pages?

+1  A: 

XHTML itself is actually XML, but I think that is not what you are asking.

XML can be used to store data in a human-readable plain text format.

See the w3schools XML tutorial about XML for more info.

Cyclone
HTML is not XML. XHTML is, but is is usually served as text/html and treated as tag soup, not XML.
David Dorward
Technically, HTML is _not_ XML. XHTML is XML, but 'classic' HTML4 is not. HTML4 allows for unclosed empty tags like `<br>` while XML requires all tags be closed, so in XHTML you must use `<br />`
LeguRi
I've updated my response. I don't feel the mistake requires a downvote however... nor does the response by Finbarr.
Cyclone
It seems to me as though someone downvoted every answer given here.
Cyclone
+2  A: 

XML - eXtensible Markup Language - is a markup language designed to give a great amount of flexibility in marking up and passing around arbitrary data. In the web, XML is normally used for transporting data through feeds, API calls and the like. XML is also frequently used for configuration files for web frameworks such as Spring.

Finbarr
+1  A: 

XML is - by name - extensible. As such it doesn't really have a main purpose. Maybe you should look at Wikipedia's List of XML Markup Languages? Or at the w3c Recommendation on XML, which stipulates the following design goals for XML:

  1. XML shall be straightforwardly usable over the Internet.
  2. XML shall support a wide variety of applications.
  3. XML shall be compatible with SGML.
  4. It shall be easy to write programs which process XML documents.
  5. The number of optional features in XML is to be kept to the absolute minimum, ideally zero.
  6. XML documents should be human-legible and reasonably clear.
  7. The XML design should be prepared quickly.
  8. The design of XML shall be formal and concise.
  9. XML documents shall be easy to create.
  10. Terseness in XML markup is of minimal importance.
LeguRi
Why downvote this?
Cyclone
@Cyclone - Either someone didn't like the design goals from the recommendation (reading them over... they're kind of disappointing) or someone's scolding us for answering a question they feel makes no sense :P
LeguRi
Maybe someone who just got the power to downvote? I thought both of our answers (well, once I fixed mine at least, yours was good from the start) were good.
Cyclone
+2  A: 

Well, XML and its associated technologies have several uses/advantages:

Plain XML on its own is really just a plain-text data storage format. The well-formed criterion of the XML specification basically ensures that an XML document can always be parsed correctly. The tag structure of an XML document makes it easier to parse and access the content and, if you're interested in the semantic web, sort of makes it easier to find meaning in the data. XML (or markup languages derived from it) is used quite a lot in data transfer because it's an intermediate, platform independent format.

XML Schema can be used to enforce a particular structure and form in an XML document, and thus can be used to create custom markup languages.

XSL (or XML Stylesheets) can be used to generate a rendered output from any XML document that links to the stylesheet, so when someone loads the XML file in their browser it will display as XHTML or a PDF or whatever else you tell it to.

Moonshield