Common files
We will start by creating a structure that is used to define the tags that are valid for our XML and JSON documents. These tags will be:
books: This is the root element that encloses all other elements.
book: This element encloses all information about a particular book.
author: This element contains the author's name.
publisher: This element contains the publisher's name.
category: This element contains the category of the book.
description: This element contains the description of the book.
name: This is an attribute of the book element in the XML example and a standard element in the JSON example. This element contains the name of the book.
The DocTags
structure will define the seven static properties that will contain the names of these seven tags. This following code shows how to define this structure:
struct DocTags { static let BOOKS_TAG = "books" static let BOOK_TAG = "book" static let AUTHOR_TAG = "author" static let PUBLISHER_TAG = "publisher" static let NAME_TAG...