This post will examine when to use eXtensible Markup Language (XML).
XML stands for eXtensible Markup Language. Most programmers would probably prefer JSON, which is the other common wire formatting language, but XML does have advantages in certain circumstances.
XML is good for representing documents. For example, the new format of Microsoft Word and PowerPoint ends in “x”, which stands for XML.
XML is a textual representation of a tree structure with nodes. There are both simple and complex elements. Complex elements have tags within tags. Look at the picture below for an example.
Further, look at another picture for an illustration of more XML basics.
Indentation is used just for readability. In other words, white space is generally discarded.
In XML, unlike HTML, you make up the tag and attribute names to be useful in what you are describing.
Indentation is often used to capture the nesting of elements.
- In the picture below, the <a> tag has two child tags <b>, and <c>.
- These tags are one level down from the root <a> tag.
- You could say <a> is the parent of <b> and <c>.
- Also, <c> is the parent of <d> and <e>.
- Text nodes and attribute nodes are considered children of the node itself.
As a Python programmer, you could write code that traverses down tags, and pulls out information.