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
26
votes
2 answers

Is it possible to set the color scheme of SwipeRefreshLayout in XML?

I'm working with SwipeRefreshLayout. I know how to setColorScheme dynamically. Is it possible to set the scheme color attribute of SwipeRefreshLayout in XML?
Huy Tower
  • 7,769
  • 16
  • 61
  • 86
26
votes
8 answers

Generate XML documentation comments for /// in Visual Studio 2010 C++

I need comment my function prototype (written in C/C++) with summary, returns, param tags. How can I persuade Visual Studio to insert xml tags after three forward slashes like in C#? I found one solution. When I rename xx.h xx.cs in C++ project, I…
user471571
  • 263
  • 1
  • 3
  • 7
26
votes
4 answers

Static android shortcuts for multiple flavors?

Is it possible to define static shortcuts for multiple flavors without duplicating the shortcuts.xml ? I have two flavors: main (package: com.test) free (package: com.test.free) The shortcuts.xml looks like this:
André Roß
  • 279
  • 3
  • 5
26
votes
5 answers

XML error at ampersand (&)

I have a php file which prints an xml based on a MySql db. I get an error every time at exactly the point where there is an & sign. Here is some php: $query = mysql_query($sql); $_xmlrows = ''; while ($row = mysql_fetch_array($query)) { …
user188962
26
votes
2 answers

Create SVG / XML document without ns0 namespace using Python ElementTree

I'm building an SVG document with ElementTree in Python 2.7. Here is the code: from xml.etree import ElementTree as etree root = etree.XML('
jfenwick
  • 1,319
  • 15
  • 17
26
votes
5 answers

How to find the number of elements in element tree in python?

I am new to element tree,here i am trying to find the number of elements in the element tree. from lxml import etree root = etree.parse(open("file.xml",'r')) is there any way to find the total count of the elements in root?
mariz
  • 509
  • 1
  • 7
  • 13
26
votes
2 answers

How to Send a body of data to XMLHttpRequest that looks like this?

How do I format this correctly? var params = { "range":"Sheet1!A4:C4", "majorDimension": "ROWS", "values": [ ["Hello World","123", "456"] ], } Then send it using POST like : var xhr = new XMLHttpRequest(); xhr.open(method, url); …
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
26
votes
5 answers

Is there a good tiny XML parser for an embedded C project?

I'm after a very tiny XML parser for an embedded project. It needs to compile down to 10-15k, doesn't need to validate, and needs to be simple and portable.
Joe
  • 269
  • 1
  • 3
  • 4
26
votes
3 answers

The attribute is not declared (Android) on basic xml attributes

I'm new to this Android development, and I find the layout of it really confusing. I'm trying to have a background image on a view, and I've tried using this example Add a background image to shape in xml Android, but it looks very bad (bitmaps you…
LaughingMan
  • 640
  • 1
  • 9
  • 18
26
votes
1 answer

How to traverse back to the parent node in the XML file by using Xpath(using XSLT) query?

Let us have a xml tree of depth N. I have traveresd the last node means i am at last note. Now i wanted to go back to some level up (say at N-3) in the xml tree from that last node. Please let me know the syntax for the XPATH query so that i can…
Santosh kumar
  • 342
  • 1
  • 3
  • 6
26
votes
4 answers

format xml string

What is the best way to format XML within a PHP class. $xml = "..."; $xml = '...'; $xml = '...'; $xml = <<
quj
  • 261
  • 1
  • 3
  • 3
26
votes
1 answer

XML to Hash conversion: Nori drops the attributes of the deepest XML elements

Summary I'm using Ruby (ruby 2.1.2p95 (2014-05-08) [x86_64-linux-gnu] on my machine, ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux] in production environment) and Nori to convert an XML document (initially processed with Nokogiri for some…
code_dredd
  • 5,915
  • 1
  • 25
  • 53
26
votes
3 answers

How to send XML POST requests with Spring RestTemplate?

Is it possible to send XML POST requests with spring, eg RestTemplate? I want to send the following xml to the url localhost:8080/xml/availability 123 Also do I want to add custom http headers on each…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
26
votes
6 answers

Which browser can show XML data transformed by XSLT?

say, if there is a file that's call data.xml, and a file that is format.xsl (or is it format.xml ?), which is to transform the XML data and format it as well using CSS, then which browser can display it? Which file should be opened? (the .xsl or…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
26
votes
3 answers

XML Schema. Base64binary type vs String type

I need to decode a Base64 string from some XML element. Is there any difference between an element defined by type="xs:base64binary" and an element defined by type="xs:string"? Some XSD developers refuse to mark encoded strings as a base64binary. If…
kirill.login
  • 899
  • 1
  • 13
  • 28
1 2 3
99
100