Sams Teach Yourself XML in 21 Days

Sams Teach Yourself XML in 21 Days

By Steven Holzner

Using XML Browsers

Calling a browser an XML browser means one of two things. As we've seen, a browser like Internet Explorer can display XML documents, and you can even use CSS or XSL to format those documents for display. However, displaying an XML document's data is one thing—making use of that data is another, and you do that in the second type of XML browser.

For example, with JavaScript you can access the data in an XML document in a browser like Internet Explorer, and you can also rewrite the HTML the browser will display. There are also dedicated XML browsers for some XML applications, and they can go far beyond HTML. We'll see one such example of a dedicated XML browser today—Jumbo, which displays XML documents using Chemical Markup Language (CML) to represent chemical molecules (and we'll build our own visual XML browser later in this book). We'll take a look at a few XML browsers now.

Using XML in Internet Explorer

Whether you love it or hate it, Microsoft's Internet Explorer is by far the most powerful general-purpose XML browser available today. You can get it at http://www.microsoft.com/windows/ie/default.asp.

The current version of Internet Explorer, version 6, is strongly XML-enabled, so we're going to see it frequently in this book. This doesn't imply a bias for or against Microsoft; it just means that there's no way to ignore this browser in a book on XML that aims to be as complete as possible. Internet Explorer can display XML documents directly, as we've already seen. It can use scripting languages like JavaScript (technically JScript, Microsoft's version of JavaScript) to access the data in an XML document and let you handle that data in code (including rewriting the HTML the browser displays, creating your own XML browser that displays your numeric data using bar graphs, and so on). It can also handle XML with both CSS and XSL style sheets, allowing you to format and display XML data as you like. It can validate XML documents using both DTDs and XML schemas (it's the only widely available browser that can use schemas). It can bind XML data to HTML controls like text boxes and buttons. There's even a special element, <XML>, that can load in XML documents automatically. We're going to see all this and more in this book.

Internet Explorer is not the only program that Microsoft has enabled for XMLXML is also used throughout the Microsoft Office suite of applications, and it's fundamental to the .NET initiative, as we're going to see towards the end of this book.

Using XML in Netscape Navigator

There's also some support for XML in the Netscape Navigator browser, which you can get at http://channels.netscape.com/ns/browsers/default.jsp. The current version is 7.0, and although this browser doesn't display raw XML documents in the same way that Internet Explorer does, you can use CSS style sheets to display XML documents in the Netscape Navigator, just as you can in Internet Explorer.

Using CML in Jumbo

Jumbo is a dedicated XML browser designed to display CML documents. You can get Jumbo free at http://www.xml-cml.org/. Jumbo can display XML (but not with style sheets), as well as using CML to draw molecules. There's an online version of Jumbo at http://www.xml-cml.org/jumbo3/jumbo3-JS/jumbo.html, and you can see it at work in Figure 2.5, drawing a picture of the ethanol molecule from CML.

02fig05.gif

Figure 2.5 Using the XML browser Jumbo to display the ethanol molecule.

Besides XML browsers like these, other tools called validators let you check your XML after you've written it.

Share ThisShare This

Informit Network