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

How to write a comment to an XML file when using the XmlSerializer?

I have an object Foo which I serialize to an XML stream. public class Foo { // The application version, NOT the file version! public string Version {get;set;} public string Name {get;set;} } Foo foo = new Foo { Version = "1.0", Name = "Bar"…
Jensen
  • 3,498
  • 2
  • 26
  • 43
26
votes
2 answers

Usage of XSLT Params; &

Please explain me how best XSLT param can be used. in terms of & Sample LOC:
Siva Charan
  • 17,940
  • 9
  • 60
  • 95
26
votes
2 answers

Extending RSS format with more fields?

I have a website that I need to create an RSS feed for. Is there a standard format for adding custom fields to an RSS feed? I would like to add a "location" element to my RSS feeds for example. I have some partners that would like to consume the…
TruMan1
  • 33,665
  • 59
  • 184
  • 335
26
votes
6 answers

Check for XML errors using JavaScript

Question: How do I syntax-check my XML in modern browsers (anything but IE)? I've seen a page on W3Schools which includes an XML syntax-checker. I don't know how it works, but I'd like to know how I may achieve the same behavior. I've already…
caleb531
  • 4,111
  • 6
  • 31
  • 41
26
votes
3 answers

Android: include a xml into an other xml

How to include a xml data into an other xml data? I have a header xml-file for my application which I want to use in my special other content xmls. Is there a ways to include the header into my content?
Xetoxyc
  • 325
  • 1
  • 3
  • 10
26
votes
2 answers

Current line number from a System.Xml.XmlReader (C# & .Net)

Does anyone know how I can get the current line number of an System.Xml.XmlReader? I am trying to record where in a file I find Xml elements.
Danielb
  • 1,608
  • 5
  • 24
  • 34
26
votes
4 answers

How to use Android View Binding with RecyclerView

This is not data binding, this is View binding which is new to Android Studio 3.6 Canary 11+ described here. For using inside an Activity it is clear, you just use it like this: Let's say we have a layout named activity_main.xml Then in the code we…
M D P
  • 4,525
  • 2
  • 23
  • 35
26
votes
3 answers

How to do an XSL:for-each in reverse order

I am looking to reverse in XSL/FO a for-each loop. for instance the xml with the xsl
Theresa Forster
  • 1,914
  • 3
  • 19
  • 35
26
votes
3 answers

How to remove namespaces from XML using XSLT

I have a 150 MB (it can go even more sometimes) XML file. I need to remove all the namespaces. It's on Visual Basic 6.0, so I'm using DOM to load the XML. Loading is okay, I was skeptical at first, but somehow that part works fine. I am trying the…
coder
  • 4,121
  • 14
  • 53
  • 88
26
votes
4 answers

'Malformed Reference Element' when adding a reference based on an Id attribute with SignedXml class

Unable to sign element by Id attribute when there's a namespace prefix: void Main() { var doc = new XmlDocument(); doc.LoadXml("Zebra"); SignedXml signedXml = new SignedXml(doc); …
Dog Ears
  • 9,637
  • 5
  • 37
  • 54
26
votes
6 answers

Get Xpath from the org.w3c.dom.Node

Can i get the full xpath from the org.w3c.dom.Node ? Say currently node is pointing to some where the middle of the xml document. I would like extract the xpath for that element. The output xpath I'm looking for is…
srinannapa
  • 3,085
  • 8
  • 49
  • 66
26
votes
3 answers

Generate HTML / Help files from VS 2010 C# XML documentation

I am looking for a good tool creating HTML / Help files from my VS2010 XML documentation. I have found some commercial tools, such as .Net documentation tool VSDocman I am sure there are more, I just list these two as examples. Also there are…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
26
votes
6 answers

Logging request/response with Apache CXF as XML

Is it possible to log the request/response as XML using CXF, ideally to a separate file so I can monitor what an application is doing?
irishguy
  • 671
  • 1
  • 9
  • 24
26
votes
8 answers

Why phpunit is not getting the correct APP_ENV as specified in phpunit.xml?

I'm using Laravel and this is my ./phpunit.xml file
koalaok
  • 5,075
  • 11
  • 47
  • 91
26
votes
3 answers

Android Failed to instantiate one or more classes

I have a running project and all the xml files are showing me the error message Android Failed to instantiate one or more classes. The program still works. I cleaned the cache and used invalidate Caches and Restart. Here the Full message: The…
Amir Khan
  • 409
  • 1
  • 6
  • 10