Compare data formats (XML, JSON, and YAML)

📘Cisco DevNet Associate (200-901 DEVASC)


1. Introduction to Data Formats

In software development and networking, systems need to exchange data with each other. For example:

  • A REST API returns device information.
  • A network controller sends configuration to routers.
  • An automation script reads configuration files.
  • A cloud platform stores application settings.

To exchange this data, systems use structured data formats.

The three most important formats for the DEVASC exam are:

  • XML (eXtensible Markup Language)
  • JSON (JavaScript Object Notation)
  • YAML (YAML Ain’t Markup Language)

You must understand:

  • Structure
  • Syntax
  • Differences
  • Use cases in networking and APIs
  • Advantages and disadvantages
  • When to use which format

2. XML (eXtensible Markup Language)

2.1 What is XML?

XML is a markup language used to store and transport structured data.

It uses custom tags to define elements.

It is widely used in:

  • Network device configuration models (NETCONF)
  • SOAP APIs
  • Legacy enterprise systems
  • Data validation systems

2.2 Basic Structure of XML

Example:

<device>
    <hostname>Router1</hostname>
    <ip>10.1.1.1</ip>
    <status>active</status>
</device>

Key Rules:

  • Every tag must have a closing tag
  • Tags are case-sensitive
  • One root element is required
  • Elements can contain:
    • Text
    • Attributes
    • Other elements

2.3 XML Features

1. Hierarchical Structure

XML data is organized in a tree format:

device
 ├── hostname
 ├── ip
 └── status

2. Attributes

<device type="router">
    <hostname>Router1</hostname>
</device>

Here, type="router" is an attribute.


2.4 XML Validation

XML can be validated using:

  • DTD (Document Type Definition)
  • XSD (XML Schema Definition)

This ensures:

  • Required fields exist
  • Data types are correct
  • Structure follows defined rules

This is important in enterprise network automation systems.


2.5 Where XML is Used in Networking

For the DEVASC exam, remember:

  • NETCONF uses XML for configuration.
  • Many older APIs return XML.
  • Some enterprise controllers use XML payloads.

2.6 Advantages of XML

  • Highly structured
  • Supports schema validation
  • Good for complex hierarchical data
  • Mature and widely supported

2.7 Disadvantages of XML

  • Verbose (large file size)
  • Harder to read
  • More complex syntax
  • Slower parsing compared to JSON

3. JSON (JavaScript Object Notation)

3.1 What is JSON?

JSON is a lightweight data format used for data exchange.

It is the most common format in REST APIs.

Almost all modern network APIs return JSON.


3.2 Basic Structure of JSON

Example:

{
  "hostname": "Router1",
  "ip": "10.1.1.1",
  "status": "active"
}

3.3 JSON Data Types

JSON supports:

  • String
  • Number
  • Boolean
  • Null
  • Object
  • Array

Example with array:

{
  "devices": [
    {"hostname": "R1"},
    {"hostname": "R2"}
  ]
}

3.4 JSON Structure Rules

  • Uses key-value pairs
  • Keys must be in double quotes
  • Curly braces {} define objects
  • Square brackets [] define arrays
  • No trailing commas allowed

3.5 JSON in Networking and APIs

For DEVASC, remember:

  • REST APIs mostly use JSON
  • Cisco APIs commonly return JSON
  • Controllers and automation scripts use JSON payloads
  • Cloud APIs use JSON

Example: A REST API response from a network device:

{
  "interface": "GigabitEthernet0/1",
  "admin_status": "up",
  "oper_status": "up"
}

3.6 Advantages of JSON

  • Lightweight
  • Easy to read
  • Easy to parse
  • Smaller than XML
  • Native support in JavaScript
  • Most popular in APIs

3.7 Disadvantages of JSON

  • No built-in schema enforcement (unless using external tools)
  • Less strict validation compared to XML
  • Cannot include comments (officially)

4. YAML (YAML Ain’t Markup Language)

4.1 What is YAML?

YAML is a human-readable data format.

It is mainly used for:

  • Configuration files
  • Automation tools
  • Infrastructure as Code

4.2 Basic YAML Structure

Example:

hostname: Router1
ip: 10.1.1.1
status: active

4.3 YAML Features

1. Uses Indentation (No Braces)

Indentation defines structure.

Example:

device:
  hostname: Router1
  interfaces:
    - GigabitEthernet0/1
    - GigabitEthernet0/2

2. Supports Lists

interfaces:
  - GigabitEthernet0/1
  - GigabitEthernet0/2

4.4 YAML in Networking

YAML is commonly used in:

  • Automation tools (like configuration management systems)
  • CI/CD pipelines
  • Infrastructure configuration files
  • Network automation frameworks

It is very common in DevOps environments.


4.5 Advantages of YAML

  • Very readable
  • Clean syntax
  • Easy to write manually
  • Good for configuration files

4.6 Disadvantages of YAML

  • Indentation-sensitive (errors easily happen)
  • Parsing can be slower
  • Less strict
  • Not commonly used in REST APIs

5. Direct Comparison (Very Important for Exam)

FeatureXMLJSONYAML
ReadabilityModerateEasyVery Easy
File SizeLargeSmallSmall
Schema ValidationStrongLimitedLimited
Used in REST APIsRareVery CommonRare
Used in NETCONFYesNoNo
Supports CommentsYesNo (officially)Yes
Human FriendlyLessGoodBest

6. When to Use Which?

Use XML when:

  • Schema validation is required
  • Using NETCONF
  • Working with legacy enterprise systems
  • Strict data structure is necessary

Use JSON when:

  • Working with REST APIs
  • Sending API requests
  • Receiving API responses
  • Building web-based applications

Use YAML when:

  • Writing configuration files
  • Working with automation tools
  • Creating infrastructure definitions
  • Managing CI/CD pipelines

7. Important Exam Points (Must Remember)

For the 200-901 DEVASC exam:

  1. REST APIs → Mostly JSON
  2. NETCONF → Uses XML
  3. YAML → Used for configuration and automation
  4. JSON is lighter and easier than XML
  5. XML supports schemas and strict validation
  6. YAML is indentation-based
  7. JSON uses key-value pairs
  8. XML uses opening and closing tags
  9. JSON and YAML are more human-readable than XML
  10. JSON is the most common data format in modern APIs

8. Key Differences in Syntax

XML

  • <tag>value</tag>
  • Verbose
  • Structured markup

JSON

  • "key": "value"
  • Uses {} and []
  • Lightweight

YAML

  • key: value
  • Uses indentation
  • No braces

9. Summary

For the Cisco DevNet Associate (200-901 DEVASC) exam:

  • Understand how XML, JSON, and YAML are structured.
  • Know which protocols use which format.
  • Know that REST APIs mainly use JSON.
  • Know that NETCONF uses XML.
  • Understand readability, validation, and size differences.
  • Be able to recognize each format quickly in exam questions.

If you clearly understand:

  • Structure
  • Use cases
  • Strengths and weaknesses
  • Networking relevance

You will be fully prepared for this section of the exam.

Buy Me a Coffee