Introducing the XML Document Object Model

Another factor when using XML is that built into the browser used to display XML data, is a structure behind the XML data set. Look again at Figure 1-3 and you should see that everything is very neatly structured into a hierarchy. This entire structure can be accessed programmatically using something called the Document Object Model, or XML DOM. Using the XML DOM a programmer can find, read, and even change anything within an XML document. Those changes can also be made in two fundamental ways:

  • Explicit data access:  A program can access an XML document explicitly. For example, one can find a particular city by using the <city> tag and the name of the city.

  • Dynamic or generic access:  A program can access an XML document regardless of its data content by using the structure of the document. In other words, a program can scroll through all the tags and the data no matter what it is. That is what the XML DOM allows. An XML page can be a list of cities, weather reports , or even part numbers for an automobile manufacturer. The data set is somewhat irrelevant because the XML DOM allows direct access to the program within the browser, which displays the XML data on the screen, as shown in Figure 1-3. In other words, a program can find all the tags by passing up and down the tree of the XML DOM.

A browser uses the XML DOM to build a picture of an XML document, as shown in Figure 1-3. The browser contains a parser that does not care what the data is, but rather how data is constructed . In other words, the DOM contains a multiple dimensional (hierarchical) array structure. That array structure allows access to all tags and all data, without the programmer having to know the contents of the tags within it and even the names of the tags. An XML document is just data and so any data can be contained within it.

When creating weather reports for people in different parts of the world, the underlying templates that make the web pages look nice are all exactly the same; only the data is different. This is where this book comes into being. Data stored in databases as traditional relation tables can be used to create XML documents that can also be stored in a database. The XML DOM allows programmatic access into XML documents stored in a database. In other words, you can create XML documents, stuff them in a database, and then use database software to access the documents either as a whole or in part using the XML DOM.

That is really what this book is about. It is, however, necessary to explain certain facets of XML before we get to the meat of databases and XML. You need to have a basic picture of things such as XML and XSL first.



Beginning XML Databases
Beginning XML Databases (Wrox Beginning Guides)
ISBN: 0471791202
EAN: 2147483647
Year: 2006
Pages: 183
Authors: Gavin Powell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net