XML has been used for a long time to exchange documents and data, and you still meet it in settings files, product feeds and public data sets. Once you can see its structure, it is easy to read.
Tags and elements
An XML element starts with an opening tag like <name> and ends with a matching closing tag </name>. Between them sits text or other elements. For example: <item><title>Pen</title><price>1200</price></item>.
Opening and closing tags must match, and the whole document needs exactly one root element. An element with no content can be closed in one go, such as <empty/>.
An element is an opening tag, content and a closing tag
A document has a single root element
Tag names are case sensitive
Attributes and text
An element can carry attributes inside its opening tag. In <item id="A1" stock="3"> the id and stock are attributes, and their values are always in quotation marks. Whether information is stored as an attribute or a child element is the author's choice, so files differ.
Characters between tags are text. Line breaks and indentation spaces can also count as text, so keep that in mind when reading.
Attribute: a name="value" pair inside the opening tag
Many files store the same facts as child elements instead
Characters such as <, & and > are written as < & >
Reading the hierarchy
XML is shaped like a tree. Under the root there are child elements, and under them more children. When an element with the same name repeats, it acts like a list: three <item> elements inside an <order> form a list of three items.
Follow the indentation to count levels and look for repeating elements, which are usually the rows. When you flatten XML into a table, each repeated element normally becomes one line.
Read from the outside in, one level at a time
A repeating element name is a candidate for rows
Separate header or metadata sections from the real data section
What changes in JSON
XML and JSON have similar structure, but they do not map one to one. Elements that have both attributes and text, and the difference between an element that appears once and one that repeats, affect the converted result.
The XML to JSON tool on this site converts inside your browser. After converting, look at how attributes are named and whether repeated elements are grouped into a list.
Attributes usually appear as separate keys
Repeated elements become a list, but a single one may become a plain value, so check later steps
Every value may arrive as text, so confirm where you need numbers
Checks before converting
XML is strict, and a single missing closing tag makes a file unreadable. If a conversion fails, suspect the structure first and open the file to look.
Files from other systems sometimes declare one encoding on the first line but are saved in another. If non-English letters look garbled, save the file again as UTF-8.
Verify that opening and closing tags match
Make sure & and < are not used raw in text
If letters look garbled, confirm the file is saved as UTF-8