Is there still a place for XML in the future?
Now that many people seem to be moving towards JSON for web communication I am wondering about why XML should continue to be used.
I appreciate that XML has many years on JSON, during which time it has been widely adopted. However, the fact that it is so well-adopted appears to be the one decisive r开发者_运维技巧eason why it should continue to be used.
Is there a good reason why XML should not gradually be phased out in favour of JSON?
Note that JSON (JavaScript Object Notation) is a lightweight data-interchange format, while XML (Extensible Markup Language) is a set of rules for encoding documents electronically.
XML, thus, is not a format but a "protocol" to encode different formats: XSLT, RSS, SOAP, RDF/XML and XHTML, just to name a few. JSON has lately become more popular as exchange format mainly in web-services, yet XML's scope is much wider than that. I'd further say that XML's role is key in the development of the semantic web.
There are some kinds of data structure that JSON cannot represent in a simple manner. For example, how would you translate this XML into JSON?
<p>This is a paragraph where <b>only some</b> of
the text is bold and some <i>is italic</i></p>
It's probably possible to do, but it won't be as simple as the XML representation. JSON is ideally suited for representing hierarchical data. XML, by contrast, is reasonably well suited for representing documents.
So for data like that (cough web pages) XML is a better fit, and I think it will be continue to be widely used.
XML is a far more powerful format than JSON. It's very easy to validate XML using schema's, transform XML to different formats using XSLT, query XML using XPath. etc.
In many cases you don't need all this functionality. In this case JSON is the better choice because it's more lightweight, offers better readability and is more compact. But there are a lot of usecases where XML is a good fit.
I guess you're forgetting that XML is not only used for the web, you can LOG processes with XML, make configuration files, transfer data, and do a bunch of other stuff. So no, JSON is definately not going to replace XML at all.
The biggest reason imho would be ENTERPRISE usage of XML. Although grands such as Google adopted json, others such as Oracle, Microsoft favour XML and XML put its roots deeply where money transactions flow, that root will not be easily changed. Another thing is in the name - Java Script Object Notation To use json effectively on the client side You have to either embed it (if You embed it into HTML, there are security issues You have to address: link text), or to convert it into another format, while XML can be easily represented by todays' means without a javascript.
The current major RDBMS vendors favors integration of XML documents into their products: Oracle, MS SQL.
What query language do you have for JSON? is there support from programming languages for querying and creating XML docs, like DOM/SAX, Linq to XML and so on? I guess not... so XML will be still present for a while.
I think JSON is going to be replacement of XML. And not only Javascript but all the popular languages are going to support JSON natively. If so, think of XSLT/XPATH replacements of JSON. Somebody will do it soon.
精彩评论