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
415
votes
8 answers

Getting attribute using XPath

Given an XML structure like so: Harry Potter 29.99 Learning XML
GurdeepS
  • 65,107
  • 109
  • 251
  • 387
415
votes
9 answers

POST XML file using cURL command line

How can I POST an XML file to a local server http://localhost:8080 using cURL from the command line? What command should I use?
Arnab Sen Gupta
  • 5,639
  • 5
  • 24
  • 17
403
votes
13 answers

What's the difference between an element and a node in XML?

I'm working in Java with XML and I'm wondering; what's the difference between an element and a node?
Philip Morton
  • 129,733
  • 38
  • 88
  • 97
397
votes
8 answers

Best XML parser for Java

I need to read smallish (few MB at the most, UTF-8 encoded) XML files, rummage around looking at various elements and attributes, perhaps modify a few and write the XML back out again to disk (preferably with nice, indented formatting). What would…
Evan
  • 18,183
  • 8
  • 41
  • 48
391
votes
28 answers

SOAP or REST for Web Services?

Is REST a better approach to doing Web Services or is SOAP? Or are they different tools for different problems? Or is it a nuanced issue - that is, is one slightly better in certain arenas than another, etc? I would especially appreciate…
user13276
  • 4,873
  • 5
  • 21
  • 16
389
votes
7 answers

XPath contains(text(),'some string') doesn't work when used with node with more than one Text subnode

I have a small problem with XPath contains with dom4j ... Let's say my XML is ABC 5 BLAH BLAH BLAH

ABC
Let's say I want to…
Mike Milkin
  • 3,961
  • 4
  • 17
  • 10
383
votes
4 answers

Populate XDocument from String

I'm working on a little something and I am trying to figure out whether I can load an XDocument from a string. XDocument.Load() seems to take the string passed to it as a path to a physical XML file. I want to try and bypass the step of first having…
StevenMcD
  • 17,262
  • 11
  • 42
  • 54
369
votes
19 answers

XmlSerializer - There was an error reflecting type

Using C# .NET 2.0, I have a composite data class that does have the [Serializable] attribute on it. I am creating an XMLSerializer class and passing that into the constructor: XmlSerializer serializer = new XmlSerializer(typeof(DataClass)); I am…
leora
  • 188,729
  • 360
  • 878
  • 1,366
368
votes
18 answers

How to view AndroidManifest.xml from APK file?

Is it possible to view Androidmanifest.xml file? I just changed the extension of the apk file to zip. This zip file contains the Androidmanifest.xml file. But I am unable view the contents of Androidmanifest.xml. It is fully encrypted. How can I…
bharath
  • 14,283
  • 16
  • 57
  • 95
365
votes
6 answers

What to use instead of "addPreferencesFromResource" in a PreferenceActivity?

I just noticed the fact that the method addPreferencesFromResource(int preferencesResId) is marked deprecated in Android's documentation (Reference Entry). Unfortunately, no alternative method is provided in the method's description. Which method…
mweisz
  • 3,899
  • 3
  • 17
  • 16
361
votes
21 answers

Center a button in a Linear layout

I am using a linear layout to display a pretty light initial screen. It has 1 button that is supposed to centre in the screen both horizontally and vertically. However no matter what I try to do the button will top align centre. I have included…
themaninthesuitcase
  • 4,771
  • 5
  • 25
  • 34
347
votes
14 answers

Android XML Percent Symbol

I have an array of strings in which the % symbol is used. Proper format for using the % is %. When I have a string in that array with multiple % it gives me this error. Multiple annotations found at this line: - error: Multiple…
zaid
  • 6,259
  • 7
  • 26
  • 20
328
votes
12 answers

How to convert JSON to XML or XML to JSON in C#?

I started to use Json.NET to convert a string in JSON format to object or viceversa. I am not sure in the Json.NET framework, is it possible to convert a string in JSON to XML format and viceversa?
David.Chu.ca
  • 37,408
  • 63
  • 148
  • 190
324
votes
7 answers

Android Replace "..." with ellipsis character

Since AVD tools 16 I'm getting this warning: Replace "..." with ellipsis character (..., …) ? in my strings.xml at this line Searching... How do I replace ...? Is it just literally …? Could someone…
Blundell
  • 75,855
  • 30
  • 208
  • 233
323
votes
22 answers

Android: remove left margin from actionbar's custom layout

I am using a custom actionbar view, and as you can see in the screenshot below, there is a blank gray space in the actionbar. I want to remove it. What have I done: res/values-v11/styles.xml