eXtensible Markup Language (XML) is used extensively throughout the software industry, and has similarities to HTML. HTML is used for webpages, whereas XML is used for data. In this video, Peter explains the most basic concept of XML: the tag. Tags are used to hold either text or complex data. In addition, tags can be nested, meaning that tags to be used to contain other tags.
- [Instructor] Now let's take a look at the data format known as XML, which stands for Extensible Markup Language. XML has its origins in HTML. HTML as you may know, stands for Hypertext Markup Language. And it's the format that browsers use to display web pages. XML is like HTML except that instead of being used to capture data for a website, it's used to capture any kind of structured data. A quick caveat, there are entire books written about XML. It can be a very complex and sophisticated language, but the basics of XML can be learned very quickly.
Here we'll focus on giving you enough information to be able to document the files. XML has two ways of handling data called tags and attributes. We'll start with tags. Tags have angle brackets on each side. Starting tags are just angle brackets and ending tags have a slash after the first angle bracket. Start and end tags must match. Meaning that for every starting tag, you should have an end tag later on that has the same text inside of the tag. Tag names can only consist of letters, numbers, and underscores and must start with a letter.
Here's an example. You can see the start tag and end tag have the same name. Here it's artist. Neither has a space in it, but the content in between the tags does have a space, The Instructors. If you don't have any content in between your start and end tags, then there's a shortcut you can use. You can end with a slash and close angle bracket. So for example a tag called invitees can be empty by using this format, which is identical to this format. What goes between the tags is called content.
Content is treated like a string, even though it doesn't have quotation marks around it. But you can also use it for numbers or true and false values. In that case, the software that reads the XML is responsible for converting it from a string into a number or a Boulean. Here are some examples. This first tag is called city. And its content is a string New York. This content has a tag called age, which is the string 2-3 that will be converted by the software to the number 23.
This tag is called enabled. And it has a string false for its content. Again, the software will convert that to the Boulean value of false. Putting tags inside other tags is how you create nested data. Here's an example. The first tag is color. Inside are three other tags called red, green, and blue. And they each have a start tag, content, and then an end tag. Finally, there's an end color tag to match the start color tag.
- The purpose of documentation
- Data types
- Structured data
- Writing JSON and XML
- Documenting one-level JSON responses
- Documenting nested JSON responses
- XML attributes and examples
- Documenting XML
- Structuring data documentation