Join James Williamson for an in-depth discussion in this video What is XML?, part of Dreamweaver CS4: Introduction to Spry.
Another important component of many Spry driven sites is the use of XML to store and display data. XML is a common markup language used to share information across multiple platforms, and is widely used across all types of web applications. As a markup language, XML is very similar to HTML. It stands for Extensible Markup Language and is the W3C's recommended specification for general-purpose markup. This means, unlike other markup languages, XML is not predefined and is made up of the tags that you create to describe the structure.
The primary purpose of XML is to share data across different systems, since any system that understands the current document structure can access and use its data. Although the tags in XML are not predefined, XML documents must conform to specific syntax to be considered valid. Well-defined XML document must have a root element. The elements must have both opening and closing tags. Invalidly nested tags are not allowed. Attributes must be in quotation marks and XML documents generally have a declaration that identifies aspects of the XML file.
The complete XML specifications can be found online at the W3C's XML Recommendation page. The typical structure of a simple XML file is to have a root element that describes the contents of the page and then repeating child objects that contain data in attributes of specific objects. Here for example, I have the contributors.xml file open. You'll notice that we have a root tag, the contributors tag, and if we go all the way down to the bottom, we'll see the contributors tag close. Inside of that, we have repeating child elements, and in this case we have one repeating child element: the photographer. In each photographer, we have an attribute value that's giving the name of the photographer, and then thus followed by the country, city, and camera.
So that repeating structure makes it very easy to store data, and any application that understands this structure could find the name of our photographers, the country of origin, the city that they live in, and the camera that they use. As for Spry, Spry can use any valid well-formed XML file to built datasets for displaying content on your pages. The XML can be freestanding or it can be generated using server-side technology based on databases or any other data source. This creates a very flexible and powerful means for storing, manipulating, and displaying data within Spry.
We will discuss creating XML datasets in Spry in greater detail later. For the moment, I would recommend becoming familiar with the structure and syntax rules surrounding XML documents, so that you can ensure you are using well-formed and valid XML within your applications.
- Validating form data to give users robust feedback
- Customizing widgets to meet the style of a web site
- Building a pull-down menu navigation system
- Pulling data from XML, HTML, and Excel spreadsheets
- Constructing datasets and widgets using code