DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1
"address": [
{
"ip": "192.168.0.2",
"netmask": "255.255.255.0"
}
]
}
}
}
>>>

Extensible Markup Language (XML)


Extensible Markup Language (XML) is a very common
data format that is used heavily in configuration
automation. Parsing XML is similar to using other data
formats, in that Python natively understands and can
support XML encoding and decoding. The following is a
very simple example of what XML structure looks like.


<device>
<Hostname>Rtr01</Hostname>
<IPv4>192.168.1.5</IP4>
<IPv6> </IPv6>
</device>

It should come as no surprise that XML looks a bit like
HTML syntax; it was designed to work hand-in-hand
with HTML for data transport and storage between web
services and APIs. XML has a tree structure, with the
root element being at the very top. There is a
parent/child relationship between elements. In the
preceding example, device is the root element that has
Hostname, IPv4, and IPv6 as child elements. Just like
with HTML, a tag has meaning and is used to enclose the
relationships of the elements with a start tag (<>)and a
closing tag (</>). It’s not all that different from JSON in

Free download pdf