XML is used to define the app’s starting point (main program) and to define its metadata. XML stands for eXtensible Markup Language and is designed to store and transport data. You may be familiar with HTML, which is also a markup language, but unlike HTML, XML is not designed for display purposes. To simplify, XML focuses on what the data is; HTML focuses on how the data looks.
Two XML files are required for TV Apps:
.TVfile extension for the
main.TVfile must be capitalized or the app will not load.
widget.xmlfile describes the app’s metadata. This file specifies information about your app such as the name of the app, author, organization, copyright information, and any security metadata.
See the Review the Sample TV App Files section for more information.
When you open an XML file, the first line in the file is the XML declaration. For example:
<?xml version="1.0" encoding="UTF-8"?>
This declaration defines the XML version (
1.0) and the character encoding (
utf-8 is the 8-bit UCS/Unicode Transformation Format).
The next line, and the last line, in the XML file describes the root element of the document (in the TV App case use the
<widget></widget> in the
main.TV file and the element
After the root element, the enclosed lines in the XML file describe child elements of the root element.
A single XML element includes everything from the element’s start tag to the element’s end tag. An XML element can contain other elements, simple text, or a mixture of both. XML elements must be properly nested. Elements can have attributes whose values must be quoted. Finally all XML elements must have a closing tag. XML tags are case sensitive so opening and closing tags must be written with the same case. For example, review the element nesting in this sample file:
XML elements must follow these naming rules:
When including text or strings in XML, be sure to replace special characters with the following entity references:
> respectively. For example:
.js file and importing it, via the
<script src="myFile.js" />
Comments in XML are the same as comments in HTML:
<!-- This is an XML comment -->