Hot answers tagged

238

The real answer is XML has an L in the name because a guy named Raymond Lorie was among the designers of the first "markup language" at IBM in the 1970'ies. The developers had to find a name for the language so they chose GML because it was the initials of the three developers (Goldfarb, Mosher and Lorie). They then created the backronym Generalized Markup ...


181

Because it is a language. A markup language, not a programming language. Notice that natural human languages like English and Spanish don't "do" anything either. In fact, technically C++ and Java and the like don't "do" anything until they're fed into a compiler and the output gets executed. Doing stuff and being a language are largely orthogonal to each ...


153

The thing that gives XML its power and a lot of its complexity is mixed content. Stuff like this: <p>A <b>fine</b> mess we're in!</p> Don't even try to do that in JSON, or manipulate it in conventional programming languages. They weren't designed for the job. This kind of question usually comes from people who forget that that the ...


104

Let Σ be a non-empty, finite set of symbols, called an alphabet. Then Σ* is the countable infinite set of finite words that can be formed by concatenating zero or more symbols from Σ. Any well-defined subset L ⊆ Σ* is a language. Let's apply this to XML. Its alphabet is the Unicode character set U, which is non-empty and ...


36

Because of the XML Schema Definition (XSD). With XML, you can have an additional file which describes the schema. It indicates, for example, that the element /a/b is an array and contains from 1 to 10 elements, or that the element /a/c is an integer. You can find an example of an XSD here. Validation of a given XML file through an XSD is supported by many ...


31

The main difference, I think, is in the fact that XML is designed to be self-explaining with its dtd's and everything. With JSON, you have to assume alot about the data you are receiving.


31

In computer science, formal language is just a set of strings, usually infinite and often described using rules (two common versions of those rules are regular expressions and formal grammars). Note that this means that all a language needs is syntax, language doesn't need to describe what each valid string means (that's called semantics). Now, this means ...


30

Semantics are important here: Marshalling implies moving the data, it does not imply transforming the data from its native representation or storage. Java Objects can be Marshalled over the wire in their native representation. Serializing implies transforming the data to some non-native intermediate representation. For example: transforming a Java Object ...


29

This page outlines quite a bit of the HTML/SGML history, and the rather convoluted rules of those two consecutive hyphens (double dash). The relevant part about SGML: To put it simply, the double dash at the start and end of the comment do not start and end the comment. Double dash indicates a change in what the comment is allowed to contain. The first --...


21

A literal translation to JSON is often less succinct and less clear. Consider: <foo> <x:bar x:prop1="g"> <quuz /> </bar> </foo> The most effective JSON representation I have seen of this: {"localName":"foo", "children": // you need to have a special array to hold all children [ {"localName": "bar", "...


21

XML is lousy for data storage. First, it is very verbose. Data stored in an XML file will take much more disk space then the same data stored in any reasonable database system. In an XML record, the name of a particular field will be stored twice, along with the string representation of the data. So, for example, to store a single integar in a field ...


20

XML can be type safe, since it it possible with XSD schemas to declare the data type of elements. A document validated against a XSD schema is guaranteed to conform to the expected types. But a XML format is not required to have a schema, so a document is not automatically type safe just by being XML. There actually exist a schema language for JSON also, so ...


18

Look at XSLT - its main use it to transform one XML dialect to another (in this case, you would output to HTML/XHTML). Update: Since the OP believes this is not a popular option, here is a link to the standard on the W3 consortium website.


17

Before choosing a different language, first make sure the language is the bottleneck. So did you actually measure the time for the 4 steps? Do you know that, for example, most waiting time for step 1 is spend in your language interpreter (and not caused by disk IO)? If the latter is the case, then chosing a language like C++ (or even assembler) may not bring ...


17

It's difficult to assess technologies when you don't have deep experience of them, but of course that's exactly when you have to make your decisions, so there's no simple answer to that dilemma. You cite two concerns: performance and usability. I'll try to address both below. Firstly, performance. Performance of course depends not only on the language but ...


15

In general terms, any unique identifier would serve for a namespace; but since it's supposed to be globally unique, the standard would have to either mandate some arbitration authority, or use another resource that is at the same time globally unique but easy to get hold and to prove it's yours. Oh, look! if you have a domain, it's obviously only yours, and ...


15

The one that wraps all of the products into a single element. You can treat it as a collection in most programming languages that offer serialization/deserialization. See XML Serialization of Arrays and Collections Arrays and collections can be serialized to XML. The standard action when using the default serializer is for the name of the collection ...


14

JSON and XML are both ways of formatting data. Both are capable of doing it perfectly well, so can JSON do everything XML does? Yes. But..... A more relevant question might not be what XML/JSON can do, but rather, what can you do with XML/JSON. There are several things you can do with XML that I don't think you can with JSON, such as translate with XLST, ...


14

To make sure that it works. Sure, if you only write out some data for your own application to read it may be enough if it just works. If you send a file to somebody else matters may be different. But even within your application you may later choose to switch the parsing library and the new one may complain about errors the old one accepted and ignored like ...


13

While you can surely write programs in XML (after all, XML's just a way of serializing a labelled tree structure with embedded strings) it's not going to help you out with programming. The hard part of programming is not writing it down, it's comprehending what exact assembly of concepts need to be told to the computer to make it do what you want to happen. ...


13

As per the standard, an XML document must have exactly one root element in order to be well formed XML. Any parser that accepts otherwise is wrong, and any XML document that is structured any different is not in fact an XML document. It is not merely discouraged by W3C, but simply against the standard.


13

This question has been asked before, but on StackOverflow. Here is the link. Quotation of the answer given by Jeffrey Hantin: Marshaling and serialization are loosely synonymous in the context of remote procedure call, but semantically different as a matter of intent. In particular, marshaling is about getting parameters from here to there, ...


13

Use a database, thats what they are for. File storage has its place, but I wouldnt use it for this kind of scenario. Consider, for example, getting a list of blog posts containing a certain tag. Doing that with a database is trivial - likely just a single SQL statement. Doing it with files will involve a lot of file manipulation.


13

We know the designers of XML were familiar with S-expressions, since XML is based on SGML, and SGML has a style sheet language, DSSSL, which uses S-expression syntax (and scheme as embedded scripting language). Nevertheless they chose a different syntax than S-expressions due to the use cases for XML. XML was initially designed to support both machine-...


12

Have you looked into SQLite? It is an embedded SQL database engine with pretty good performance, and it gives you the power of SQL (there are some advanced features it doesn't have, check their website for details), which might make it easier and faster to access your data than reading and processing DOM objects. I believe it's also written in C so ...


12

In your question title, you ask about HTML, SGML and XML as if they are the same thing, but they are not. In fact, they are very different in precisely that area which you are asking about. In particular, SGML has both Null End Tags and Implied End Tags (and Implied Elements as well), and since HTML is an application of SGML, it inherits those. Null End ...


12

I think YAML is best fit for your case. To my understanding, YAML is the de facto standard format for configuration files that need to be edited by hand. Many programming languages have a library for reading and/or writing YAML. JSON is closely related to YAML, but is little bit less easier to write than YAML, and is used more for communication between web ...


Only top voted, non community-wiki answers of a minimum length are eligible