---
# System prepended metadata

title: XML and JSON

---

# XML and JSON

A hands on tutorial of the XML and JSON data formats, and how they are found/used/experienced in the GLAM space.  

Typically tutorials for both XML and JSON are centered around the use of these data types in relation to HTML and webpages. 

In GLAM we often encounter XML, and increasingly JSON as a data container format that is not related to HTML or web pages. 

This session is an opportunity to explore the data formats in a GLAM context, and how they relate to content and information we use in our work. 

Sample files:

https://github.com/jayGattusoNLNZ/JSONnXML 


## Schedule

1. Intro (10 mins)
2. XML (1 hour 15 mins)
2.1 What is it? (20 mins)
2.2 How to 'read' it (20 mins)
2.3 How to 'use' it (20 mins)
2.4 Experiments (15 mins)
4. Break (10 mins)
5. JSON (1 hour 15 mins)
5.1 What is it (20 mins)
5.2 How to 'read' it (20 mins)
5.3 How to 'use' it (20 mins)
5.4 Experiments (15 mins)

## On the question 'XML vs JSON?'

JSON vs XML
https://hackr.io/blog/json-vs-xml

A Deep Look at JSON vs. XML, Part 1: The History of Each Standard
https://www.toptal.com/web/json-vs-xml-part-1

A Deep Look At JSON vs. XML, Part 2: The Strengths and Weaknesses of Both
https://www.toptal.com/web/json-vs-xml-part-2

### ____________________________________________________

## XML 


### Objectives 
* Basic structure of / tour of XML
* How to open XML files! 
* How to read/validate XML files
* Basic rules (nesting, order, reserved chars etc)
* Adding elements
* Extending XML

### Not covered
* Validation via DTD / XLT
* Namespaces and what all that means/does
* Computational Access

### _____

### Tools:

XML can be viewed in any browser, or text editor. 

Some browsers have better tools/methods for reading XML:   
https://chrome.google.com/webstore/detail/xml-formatter/ejmpbcebpllmffkidemmlecpgboklcme 
https://opensource.com/article/18/12/xml-browser

If you have access to good text editors, you can also get a better experience:

Notepad++ https://notepad-plus-plus.org/downloads/ 


### XML Tutorial Sources: 

XML Tutorial
https://www.w3schools.com/xml/default.asp

Python XML with ElementTree: Beginner's Guide
https://www.datacamp.com/community/tutorials/python-xml-elementtree 

### Online validator:

https://www.xmlvalidation.com/
https://codebeautify.org/xmlvalidator


[Don't submit any XML data that you're not sure about - check for privacy, confidentiality, or any other restrictions first. ]

### Rules

XML documents must contain one root element that is the parent of all other elements
If there is a header line, called the XML prolog, it comes first
All elements must have a closing tag
XML tags are case sensitive
All elements must be properly nested within each other
The attribute values must always be quoted
`<` and `&` are strictly illegal in XML - use entity references: `&lt;` and `&amp;`
`>` and  `'` and `"` should be avoided - use entity references:  `&gt;` and `&apos;` and `&quot;`
White-space is preserved in XML

https://www.w3schools.com/xml/xml_syntax.asp


### ____________________________________________________

## JSON

### Objectives
* Basic structure of / tour of JSON
* How to open JSON files
* How to read/validate JSON data
* Basic rules (nesting, order, reserved chars etc)
* Adding elements
* Extending JSON

### Not covered
* Validation via schema
* Namespaces and what all that means/does
* Computational access

### _____

### Tools:

JSON can be viewed in any browser, or text editor. 

Some browsers have better tools/methods for reading JSON:   
https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa?hl=en
https://gist.github.com/dr7githu/e34e9f5e817e546ea83fa07356acf385 

If you have access to good text editors, you can also get a better experience:

Notepad++ https://notepad-plus-plus.org/downloads/ 

### JSON Tutorial Sources:

JSON - Introduction
https://www.w3schools.com/js/js_json_intro.asp

JSON Data in Python
https://www.datacamp.com/community/tutorials/json-data-python

The Complete JSON Tutorial – Quickly Learn JSON
https://www.codewall.co.uk/the-complete-json-tutorial-quickly-learn-json/

### Online Validator:

https://jsonlint.com/ 
https://codebeautify.org/jsonvalidator

[Don’t submit any JSON data that you’re not sure about - check for privacy, confidentiality, or any other restrictions first. ]

### Rules

Data is in name/value pairs
Data is separated by commas
Curly braces hold objects
Square brackets hold arrays

https://www.w3schools.com/js/js_json_syntax.asp

