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
5 answers

F# XML parsing

this c# code is probably not the most efficient but gets what I want done. How do I accomplish the same thing in F# code? string xml = " " + " test@email.com " + " …
TonyAbell
  • 1,310
  • 4
  • 19
  • 28
26
votes
4 answers

Define Spring JAXB namespaces without using NamespacePrefixMapper

[Heavily edited as understanding progresses] Is it possible to get Spring Jaxb2Marshaller to use a custom set of namespace prefixes (or at least respect the ones given in the schema file/annotations) without having to use an extension of a…
Gary
  • 7,167
  • 3
  • 38
  • 57
26
votes
4 answers

best way to implement custom pretty-printers

Customizing pprint.PrettyPrinter The documentation for the pprint module mentions that the method PrettyPrinter.format is intended to make it possible to customize formatting. I gather that it's possible to override this method in a subclass, but…
intuited
  • 23,174
  • 7
  • 66
  • 88
26
votes
2 answers

Select a subset of childnodes by name

Given this xml doc //... same child nodes //....…
accand
  • 531
  • 1
  • 8
  • 17
26
votes
10 answers

StAX XML formatting in Java

Is it possible using StAX (specifically woodstox) to format the output xml with newlines and tabs, i.e. in the form: someData instead of: someData If…
Lehane
  • 47,588
  • 14
  • 53
  • 53
26
votes
6 answers

How to ignore comments when reading a XML file into a XmlDocument?

I am trying to read a XML document with C#, I am doing it this way: XmlDocument myData = new XmlDocument(); myData.Load("datafile.xml"); anyway, I sometimes get comments when reading XmlNode.ChildNodes. For the benefit of who's experiencing the…
tunnuz
  • 23,338
  • 31
  • 90
  • 128
26
votes
10 answers

What is XML good for and when should i be using it?

I'm curious, I've been developing pretty powerful websites/web apps, and I've never learned XML, even odder I've never really felt the need to. It's not like curl or Prepared Statements where, before knowing what they did and how they worked, I had…
Haroldo
  • 36,607
  • 46
  • 127
  • 169
26
votes
9 answers

Reference to undeclared entity exception while working with XML

I am trying to set the innerxml of a xmldoc but get the exception: Reference to undeclared entity XmlDocument xmldoc = new XmlDocument(); string text = "Hello, I am text α   – —" xmldoc.InnerXml = "

" + text + "

"; This…
Rob
  • 1,163
  • 2
  • 18
  • 28
26
votes
7 answers

How does JSON compare to XML in terms of file size and serialisation/deserialisation time?

I have an application that performs a little slow over the internet due to bandwidth reasons. I have enabled GZip which has improved download time by a significant amout, but I was also considering whether or not I could switch from XML to JSON in…
Nick Bolton
  • 38,276
  • 70
  • 174
  • 242
26
votes
2 answers

How to Parse Big (50 GB) XML Files in Java

Currently im trying to use a SAX Parser but about 3/4 through the file it just completely freezes up, i have tried allocating more memory etc but not getting any improvements. Is there any way to speed this up? A better method? Stripped it to bare…
Joe Maher
  • 5,354
  • 5
  • 28
  • 44
26
votes
4 answers

How do I configure a RollingFileAppender to roll by date and size with log4net?

I am configure log4net to use a composite RollingFileAppender so that the current file is always named logfile.log and all subsequent files are named logfile-YYYY.MM.dd.seq.log where seq is the sequence number if a log exceeds a certain size within…
Ryan Taylor
  • 8,740
  • 15
  • 65
  • 98
26
votes
1 answer

What's the best JSON or JS object to XML converter module for Node JS

I need to build a relatively simple XML document with some hierarchy and some attributes from a JS object. I stand now before choosing one of these…
Christiaan Westerbeek
  • 10,619
  • 13
  • 64
  • 89
26
votes
6 answers

How to prevent JAXB from writing unused namespaces during marshalling

Has someone ever been able to remove unused namespaces during marshal of an object using JAXB? Here is a link of the requested feature: https://github.com/javaee/jaxb-v2/issues/103 (see description) Is there a property for configuring JAXB for…
TimothyBrake
  • 551
  • 6
  • 9
26
votes
2 answers

What's the difference between JAXB annotations put on getter versus setters versus members?

Title says it all. I would like to know what is the principial difference between putting JAXB annotation (like @XmlElement) on field / getter / setter. It seems to me that (in simple cases) it does not matter. E.g. lets take this class A { …
stewenson
  • 1,282
  • 3
  • 15
  • 34
26
votes
6 answers

Border color on Android button

I have a button created and have set the background color and text color as can be seen below. My question is: how do I set the buttons border color? I want to set the border color to white Here is the button in my res -> layout ->…
heyred
  • 2,031
  • 8
  • 44
  • 89
1 2 3
99
100