So friends, let's take a look at some other file formats, namely XML.
And one that we have briefly looked at, this one is YAML but we'll look at it
in a little bit more detail.
So let's first start off with XML. So this is known as the Extensible Markup
Language.
Now one thing to note about XML is that there is an extensive use, if you will
excuse the pun,
an extensive use of these particular arrows, see this year.
Here we have our opening arrow and our closing arrow.
In XML, speak, these are basically referred to as tags. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
In XML, speak, these are basically referred to as tags.
And pretty much these tags are used to describe the structure of our data.
And then within the tags, we're going to have actual data that we can work with
.
Now one thing to state is XML is apparently human readable, at least it was
designed to be,
but in my opinion, I think it is an absolute headache to look at.
Okay, okay, I must admit, you still can read the data, especially if you only
have a little bit of it.
But honestly, if you get a really large set of data and it's all formatted in WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
But honestly, if you get a really large set of data and it's all formatted in
XML,
trying to read it yourself, I'm man, you're just asking for a migraine, it
really is quite a lot.
Now the reason why I'm even bringing this up is that it happens to be the file
format
utilized in the netcon protocol pretty much.
This is one of the more modern interfaces for network automation.
And later on within this course, we will actually look at netcon in a little
bit more detail.
So really all I'm doing is planting a seed and prepping the ground,
kind of slowly introducing you into the concept of what we're talking about
here.
So let me just briefly show you how the data would look. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So let me just briefly show you how the data would look.
This time not formatted in JSON, but instead XML.
Okay, okay, so this is pretty much the same information once again.
You can see the extensive use of these arrows, which ultimately make your tags
notice this, okay?
Here's the key distinction of XML.
We have our opening tag, for example, so we have a little arrows, then the tag
within,
that is the opening tag, and then the corresponding closing tag is pretty much
the same,
but it also has a forward slash in it.
See that right there?
So this one opens it, and when we add the forward slash, that is the one to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So this one opens it, and when we add the forward slash, that is the one to
close it.
And anything within here is ultimately this set of data.
So pretty much here is the VLANs right here.
We can see the opening tag for the name, the closing tag.
Inside, we actually have data, which is the name marketing.
Again, we have an opening tag of number, closing tag of number.
Inside within once again, we have our value, the number 10.
Same thing is true for SVI.
Here's the closing tag, and here is the data for IP address and subnet mask,
and again, if I just happen to say, for example, scroll on out a little bit.
We can see the data right here.
Now, one thing to note about XML is once again, it is not dependent on white WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now, one thing to note about XML is once again, it is not dependent on white
space,
and it does not care about indentation.
So whilst this has been rather neatly formatted, I suppose neatly in a loose
sense of the word,
to have this type of nested hierarchical structure, this is not actually a
feature of XML,
it doesn't actually mandate that this data has to be this way.
In fact, what I could do is encourage it.
As you could easily have all your data just like this,
no indentation, because like I say, it does not actually matter.
XML does not care.
This is just as valid as the previous layout. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
This is just as valid as the previous layout.
It's just a little bit more difficult for us as humans to eyeball and read this
information.
But crucially, like I say, it doesn't break the actual data.
Now, one thing I will say about XML,
is when it comes to having data stored in this format,
that is a super, do-per-powerful and efficient way to query
very particular piece of information held in this format.
And this is something known as X-path filtering.
Now, I'm not going to go into the details of X-path, it can be quite involved,
it can be quite detailed.
But just understand, despite the fact that this looks like a bit of a mess, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
But just understand, despite the fact that this looks like a bit of a mess,
programmatically, we can draw all sorts of correlations between very particular
pieces of data
within here and parse out information super precisely.
So what I'm saying here is, is that it does have some very particular benefits.
Okay, so that will do us from now on XML, we don't want to get a headache.
Let's look at the more friendly one.
This time we'll look at YAML data.
Okay, okay, here is the same information, structured, utilising YAML.
Now, how much nicer does this look?
How much easier is this on the eye? WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
How much easier is this on the eye?
After looking at XML, this is like getting a good massage, honestly.
It's just so much better.
Okay, so big difference between JSON and XML with YAML,
YAML is super sensitive to white space.
If you happen to change the indentation,
you can very easily break your YAML or at least completely alter the way the
data has been structured.
So white space and as we can see here, indentation is obviously very important.
Now, one thing to state here with respect to JSON and YAML,
both are fairly human readable.
YAML being more so in my opinion, more people's opinion. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
YAML being more so in my opinion, more people's opinion.
Now, one thing you cannot do in JSON is you actually cannot write comments.
This is not actually possible within these documents.
However, when it comes to YAML,
we can absolutely inject comments into our configurations.
So this is very, very useful for, say, for example,
storing your configuration data, because what you can do is you can annotate
this information
with some context and not have actually effect the document itself.
So, say, for example, what I could do here is add a hash tag that's now known.
And anything after here is going to be accepted by YAML as a comment, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And anything after here is going to be accepted by YAML as a comment,
basically ignored.
So it's just here for your own context and annotation.
So I could annotate this with saying, you know, using private IP addresses,
because it's a test.
Whatever it may be, maybe you want to say all SVIs,
must use the first available address and the network range.
The actual examples here are trivial.
Doesn't actually matter.
The point is is that if you use this particular file format,
say, for example, for modeling your configurations, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
say, for example, for modeling your configurations,
then say, for example, you want a junior engineer to make an update to the
network.
What the cool thing is is that the junior engineer can just modify this very
readable file.
It's much easier for a junior engineer to interpret,
but more importantly, we can leave very specific notes about particular
configurations
that add additional context and give direction.
Very, very useful.
Now, these three file formats are not the only types you can use for data
serialization,
but in the world of network automation,
JSON, XML and YAML are certainly the most common ones that you're going to see. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
JSON, XML and YAML are certainly the most common ones that you're going to see.
So it's a good idea to become familiar with them,
so that when you inevitably stumble upon these file formats,
well, they don't trip you up and confuse you.