Questions tagged [xml]

XML (Extensible Markup Language) is a structured document format defining text encoding rules. When using this tag include additional tags such as programming language, tool sets, XML technologies being used, and other tags describing the environment of the problem posted. XML flexibility lends to a wide variety of uses for human and machine data transfer so be specific as to tools and libraries.

Extensible Markup Language

Wikipedia defines XML as follows:

XML (Extensible Markup Language) is a set of rules for encoding documents in both human-readable and machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards.

Extensible - XML is extensible. It lets you define your own tags.

Markup - The most attractive feature of XML has to be its ability to allow its user to create their own tags. The tags that can be created will be similar to tags in HTML. But with XML you are afforded the opportunity to define your own tags.

Language - XML is a language that is very similar to HTML. But it’s much more flexible because it allows creating custom tags. In this way XML acts like a meta-language: a language that allows us to create or define other languages. For example, with XML we can create other languages, such as RSS.

In short, XML:

  • is designed to transport and store data
  • is a flexible and simpler text format derived from SGML (ISO 8879)
  • is a markup language much like HTML
  • was designed to be self-descriptive
  • stands for eXtensible Markup Language
  • is a W3C Recommendation
  • does not DO anything
  • is just information wrapped in tags

The design goals of XML emphasize simplicity, generality, and usability over the Internet. It is a textual data format with strong support via Unicode for the languages of the world. Although the design of XML focuses on documents, it is widely used for the representation of arbitrary data structures – for example in web services, configuration/settings, and GUI, workflow, and task definition.

XML is also used in some protocols for distributed computing and web services such as SOAP and HTML-RPC and REST (see also SOAP vs REST (differences) )

Many application programming interfaces (APIs) have been developed to aid software developers with processing XML data, and several schema languages exist to aid in the definition of XML-based languages. Schemas are usually defined with an external namespace, but XML also allows you to define tags within the document itself.

XML was introduced in 1996 as version 1.0 and has reached version 1.1 in 2004 which has some unique features but isn't very widely spread.

Structure

As already stated, the structure of XML is very similar to the structure of HTML. That is, an XML document is a tree structure with the nodes being called tags (similar to HTML elements), and if tag T2 is descendant of tag T1, then T2 is inside T1.

XML Technologies

  • XQuery (the XML Query language) is a language for querying XML documents much like querying relational databases.
  • XPath (the XML Path language) is a language for finding information in an XML document; it is a subset of XQuery.
  • XSLT (eXtensible Stylesheet Language Transformations) is used to transform XML documents.
  • XLink (the XML Linking language) defines methods for creating links within XML documents.
  • XPointer (the XML Pointer language) allows hyperlinks to point to specific parts (fragments) of XML documents.

XML versions

There are currently two versions of XML in use.

XML 1.0 is the original version of XML.

XML 1.1 is currently the newest version. Notable changes from XML 1.0 include:

  • XML 1.0 is forward compatible with the Unicode standard.

  • More freedom with using line breaks.

  • Support for additional control characters.

Example Document

The following text is defined using XHTML and entity references; the text serves as an example of XML syntax and structure:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
  <!ENTITY hello "Hello, World!">
]>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>&hello;</title>
  </head>
  <body>
    <div>&hello;</div>
  </body>
</html>

Resources

The following links provide additional information to learn about XML:

Related Tags

213775 questions
27
votes
4 answers

XML Signature: How to calculate the digest value?

I have an XML like this A B C
user252816
  • 563
  • 4
  • 12
  • 21
27
votes
12 answers

Intent from Fragment to Activity

I was trying to go to another page using button, but it always fail. Here is my First Class with its XML: public class FindPeopleFragment extends Fragment { public FindPeopleFragment(){} @Override public View…
AndroidNewbie
  • 669
  • 3
  • 16
  • 23
27
votes
6 answers

xml2js: how is the output?

I m trying to use the node.js module xml2js My code is quite simple: function testparse(pathname, callback) { var parser = require('xml2js').Parser(), util = require('util'), fs = require('fs'), fs.readFile(pathname, function…
DrakaSAN
  • 7,673
  • 7
  • 52
  • 94
27
votes
4 answers

What is XML BOM and how do I detect it?

What exactly is the BOM in a ANSI XML document and should it be removed? Should a XML document be in UTF-8 instead? Can anyone tell me a Java method that will detect the BOM? The BOM consists of the characters EF BB BF .
djangofan
  • 28,471
  • 61
  • 196
  • 289
27
votes
8 answers

Android Studio: Error parsing XML & URI is not registered

After adding a new Activity to my project I get following error while compiling the layout Gradle: Error parsing XML: not well-formed (invalid token)
Jonas
  • 1,432
  • 3
  • 20
  • 27
27
votes
2 answers

Does .Net 4.5 support XML 1.1 yet (for characters invalid in XML 1.0)?

This is in the context of Web Services (client end). I need to interface with a back-end system (Java) and it is a requirement to transmit some control characters in the  and  range. I'm well aware that XML 1.0 doesn't support this, but am…
RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262
27
votes
4 answers

Omitting the standalone attribute in xml declaration when using Java DOM + Transformer.

Is there any way to tell the Transformer (when serializing an XML document using DOM), to omit the standalone attribute? Preferably without using a hack, i.e. ommitting the whole XML declaration and then prepending it manually. My current…
vicsz
  • 9,552
  • 16
  • 69
  • 101
27
votes
1 answer

How to prevent XDocument from adding XML version and encoding information

Despite using the SaveOptions.DisableFormatting option in the following code: XDocument xmlDoc = XDocument.Load(FileManager.SourceFile); string element="campaign"; string attribute="id"; var items = from item in xmlDoc.Descendants(element) …
Ein Doofus
  • 495
  • 1
  • 5
  • 12
27
votes
5 answers

How to use iTMSTransporter?

I have 50 achievements to upload to iTunes Connect. I have read that you can do this using iTMSTransporter however I cannot find references or examples of the script or metadata.xml file. I have found the file…
abe
  • 4,046
  • 6
  • 29
  • 33
27
votes
3 answers

Java: Writing a DOM to an XML file (formatting issues)

I'm using org.w3c XML API to open an existing XML file. I'm removing some nodes , and I'm adding others instead. The problem is that the new nodes that are added are written one after the other, with no newline and no indentation what so ever. While…
Vhaerun
  • 12,806
  • 16
  • 39
  • 38
27
votes
9 answers

Is there an XML Editor with grid view similar to that of XMLSpy?

I have been testing out a few different xml editor/viewers and I can't seem to find any that have a feature that is comparable to XMLSpy's grid view. Another feature I'd like to find, but is a deal breaker would be XMLSpy's ability to "Copy as…
swolff1978
  • 1,845
  • 7
  • 28
  • 44
27
votes
5 answers

What is the best way to convert XMLGregorianCalendar to MM/dd/yyyy hh:mm String?

What is the best way to convert XMLGregorianCalendar objects to 'MM/dd/yyyy hh:mm' String?
kostepanych
  • 2,229
  • 9
  • 32
  • 47
27
votes
3 answers

Embedding XML in HTML

How would one go about embedding XML in a HTML page? I was thinking using CDDATA would be the best approach but I get errors in the HTML document when the page loads. I'm needing to embed a XML document for…
amcdnl
  • 8,470
  • 12
  • 63
  • 99
27
votes
3 answers

xmlns=''> was not expected. - There is an error in XML document (2, 2)

Im trying to deserialize the response from this simple web service Im using the following code: WebRequest request = WebRequest.Create("http://inb374.jelastic.tsukaeru.net:8080/VodafoneDB/webresources/vodafone/04111111"); WebResponse ws =…
user1384603
  • 545
  • 5
  • 12
  • 16
27
votes
1 answer

How do I specify XML serialization attributes to support namespace prefixes during deserialization in .NET?

I have a following XML: John Wayne 37 How do I define XML serialization attributes on a class to support…
Piotr Owsiak
  • 6,081
  • 8
  • 39
  • 42