Reading XML

I l @ ve RuBoard

The software that reads and displays an XML document is called an XML parser . PHP contains the Expat XML parser. However, using PHP's COM interface, you can also use the Microsoft XML (MSXML) parser (which is used throughout the Microsoft product line). The parser's job is to allow you to work with XML documents ”creating them, deleting them, or adding to them as well as displaying them.

The job of displaying an XML document varies, depending on the XML parser. In a web browser such as Internet Explorer, you can use the MSXML parser to display the document directly in the browser, as shown in Figure 8.1. You can use Expat to display the XML document, but you must use a language such as PHP to finish displaying the document (that is, output the XML to a displayable format, such as HTML). You will often use an XML parser in this sense. Displayed in its raw form (as can be done in Internet Explorer, as shown in Figure 8.1), it is confusing to read and would not fit into most web applications. What you often need to do is use the parser to read the XML document and display it in an easy-to-read manner. Luckily, both Expat and MSXML let you do this. (It's luckier still that MSXML is dual-purpose in this sense ”it can parse and display.) Later in this chapter you will see how to display an XML document. First, let's look more carefully at what makes up an XML document.

Figure 8.1. The XML file displayed directly in Internet Explorer.

graphics/08fig01.gif

I l @ ve RuBoard


PHP Programming for Windows
PHP Programming for Windows (Landmark (New Riders))
ISBN: 0735711690
EAN: 2147483647
Year: 2002
Pages: 99

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