From the course: Learn API Documentation with JSON and XML

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

XML attributes and examples

XML attributes and examples

From the course: Learn API Documentation with JSON and XML

Start my 1-month free trial

XML attributes and examples

- [Voiceover] In addition to content, tags can have attributes as a way to hold simple data. This data takes the form of a string. Attributes are key value pairs, much like what you have in JSON, where both the key and value are strings. Although both values are strings, the keys do not have quotes around them. And the rules for attribute keys follow the same rules as those for tags. Only letters, numbers, and underscores, and they must start with a letter. The values do have quotes around them. Attributes are placed inside of the start tag. There are many ways to design XML files, and the most common design is not to use attributes for data. Instead they are used to indicate some property about the data that's in the content of the tag. Another way to phrase this is to say that they are used for metadata. One reason for doing it this way is that the APIs often provide the option of using either JSON or XML. By using attributes sparingly, it makes it easier to have a simple mapping…

Contents