| << 18.3.0- XML as Data | Chapter18 | 18.3.2- The W3C Document Object Model >> |
XML Parsers
For a system to use XML, it requires two components:
- The XML processor
- The application
The first part, known as the XML processor, has the job of checking that the XML file follows the specification. Then, so that the computer can interpret the file, the XML processor creates a document tree (which we shall see in a moment). It is the parser that takes up the role of the XML processor. The application is the part that then uses the data in the tree.
As we mentioned earlier, validating parsers can also check that the syntax of your document instance, such as the books.xml file, is written in accordance with the markup language that defined it, which would be specified in the DTD, such as our books.dtd schema (or a different type of schema).
Parsers expose the document as a tree – essentially a structured set of objects and properties that implement the methods that allow you to work with them. Several do this in accordance with the Document Object Model specification from the W3C, which we shall meet in a moment.
This is, in fact, what happens when Internet Explorer 5 opens an XML document, it loads it using a parser called MSXML, which is a COM component housed in msxml.dll. It can be used like any other COM component in both client and server applications and web pages.
There are many implementations of parsers available, written in a number of languages and for different uses. MSXML is also available as a standalone parser for those who need to re-distribute it, and for use on servers that do not have IE5 installed. As this book is about ASP 3.0 (which comes with Windows 2000 which, in turn, includes IE5) you should have this installed on your machine. If not, you can download the standalone component from Microsoft at http://msdn.microsoft.com/xml/. You just register it like any other COM component. Go to the Start menu, and choose Run. Then type:
Regsvr32 c:\folder_name\msxml.dll
To use the MSXML parser on the client, the client machine must have IE5 installed, or have the standalone component registered. Then we can create an instance of it, as we do any other client side component, using:
CreateObject("microsoft.xmldom")
On the server, in our ASP pages, we use:
Server.CreateObject("microsoft.xmldom")
In order to manipulate the XML document, MSXML implements the W3C XML Document Object Model, so let's turn our attention to that for a moment.
| << 18.3.0- XML as Data | Chapter18 | 18.3.2- The W3C Document Object Model >> |

RSS

