• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Rowell Dionicio

Get Techie With It

  • Home
  • About
  • Resources
    • Archives
    • Book List
    • YouTube
  • Learn
    • DevNet Associate
    • PCNSA Certified
  • Blog
  • Contact
  • Show Search
Hide Search

XML Basics for DevNet

October 23, 2019 By Rowell Leave a Comment

Understanding the basic concepts of the XML format and the content it contains will be important when dealing with APIs and writing scripts.

I continue my series in studying for the Cisco DevNet Associate certification.

XML stands for Extensible Markup Language and is a way to describe sets of data. Its purpose is to be human readable and to be used to store and transport data.

When it comes to networking, we can use XML to exchange data between systems and also store data. With the use of APIs, we can query network devices and change their settings.

Basic structure of XML as an example:

<network>
    <name>Meraki San Francisco - wireless</name>
    <total_usage_kbytes>1097882601473</total_usage_kbytes>
    <total_user_count>6680</total_user_count>
    <node>
        <mac>88:15:44:60:76:48</mac>
        <name>1.01</name>
        <lat>37.7706845469377</lat>
        <lng>-122.387316962811</lng>
        <is_active>true</is_active>
        <seconds_since_update>11</seconds_since_update>
        <channel>1</channel>
        <last_reported_from>184.23.135.130</last_reported_from>
        <gateway_metric>1</gateway_metric>
        <is_gateway>true</is_gateway>
        <users_in_last_day>9</users_in_last_day>
        <usage_in_last_day_in_kbytes>959578</usage_in_last_day_in_kbytes>
    </node>
</network>

It reads straight forward where you have network as the root element containing child elements such as name and node.

What we can do with this data is manipulate it through scripting or software by sending, receiving, or displaying the data.

XML Structure
Think of XML as a tree-like structure. There are different types of nodes but we should be very comfortable with elements and data.

  • document node
  • elements
  • data
  • processing instructions
  • comments

When we work with XML we must follow some rules so it maintains the correct structure used across systems. It’s rather simple to follow this structure just by looking at the example above.

An XML element must have a start and end-tag enclosed in angle brackets. An example is <Hostname>..</Hostname>. And it is possible to have an empty element but, again, it should have a start-tag and end-tag.

From the example you can see that some XML elements are nested. When nesting elements, they must be closed properly.

So let’s take a look at that example again:

<network>
    <name>Meraki San Francisco - wireless</name>
    <total_usage_kbytes>1097882601473</total_usage_kbytes>
    <total_user_count>6680</total_user_count>
    <node>
        <mac>88:15:44:60:76:48</mac>
        <name>1.01</name>
        <lat>37.7706845469377</lat>
        <lng>-122.387316962811</lng>
        <is_active>true</is_active>
        <seconds_since_update>11</seconds_since_update>
        <channel>1</channel>
        <last_reported_from>184.23.135.130</last_reported_from>
        <gateway_metric>1</gateway_metric>
        <is_gateway>true</is_gateway>
        <users_in_last_day>9</users_in_last_day>
        <usage_in_last_day_in_kbytes>959578</usage_in_last_day_in_kbytes>
    </node>
</network>

<name> is nested under <node>. Nested elements should be closed prior to the element above it. Additionally, the element names are case sensitive.

If we wanted to add comments we can do so with the syntax <!—- this is a comment – >

<device>
    <!--THIS IS A COMMENT-->
    <Hostname>R1</Hostname>
    <IPv4>192.168.1.1</IPv4>
</device>

Here’s an XML example from the Meraki sandbox:

<network>
    <name>Meraki San Francisco - wireless</name>
    <total_usage_kbytes>1097882601473</total_usage_kbytes>
    <total_user_count>6680</total_user_count>
    <node>
        <mac>88:15:44:60:76:48</mac>
        <name>1.01</name>
        <lat>37.7706845469377</lat>
        <lng>-122.387316962811</lng>
        <is_active>true</is_active>
        <seconds_since_update>11</seconds_since_update>
        <channel>1</channel>
        <last_reported_from>184.23.135.130</last_reported_from>
        <gateway_metric>1</gateway_metric>
        <is_gateway>true</is_gateway>
        <users_in_last_day>9</users_in_last_day>
        <usage_in_last_day_in_kbytes>959578</usage_in_last_day_in_kbytes>
    </node>
</network>

Share this:

  • Facebook
  • LinkedIn
  • Twitter

Related

Filed Under: Coding, DevNet Associate Tagged With: 200-901, devnet associate, xml

About Rowell

Wi-Fi expert. Coffee addict ☕️. Tech nerd. Business owner.

Reader Interactions

Leave a Reply Cancel reply

Primary Sidebar

Recent Posts

  • Passed Palo Alto Networks Certified Security Administrator (PCNSA)
  • 5 Years Running
  • Q4 2021 and Yearly Income Report
  • I PASSED JNCIA-MistAI
  • Admins and Role-Based Access Control – PCNSA

Categories

  • bschool
  • Certifications
  • Coding
  • DevNet Associate
  • Events
  • Lab
  • Networking
  • Personal
  • Podcasting
  • Professional
  • Reviews
  • Security
  • Short Stories
  • Uncategorized
  • Wireless

Archives

  • May 2022
  • January 2022
  • December 2021
  • November 2021
  • August 2021
  • July 2021
  • April 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • November 2018
  • September 2018
  • August 2018

Copyright © 2022 · Written by Rowell Dionicio · You're awesome.