13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

810 Chapter 33 Connecting to <strong>Web</strong> Services with XML <strong>and</strong> SOAP<br />

Listing 33.1<br />

Continued<br />

<br />

0596005431<br />

<strong>Web</strong> Database Applications with <strong>PHP</strong> &amp; <strong>MySQL</strong>,<br />

2nd <strong>Ed</strong>ition<br />

<br />

<br />

<br />

<br />

The document begins with the following line:<br />

<br />

This st<strong>and</strong>ard declaration tells you the following document will be XML using UTF-8<br />

character encoding.<br />

Now look at the body of the document.The whole document consists of pairs of<br />

opening <strong>and</strong> closing tags, such as what you see between the opening <strong>and</strong> closing Item<br />

tags:<br />

<br />

...<br />

Item is an element, just as it would be in HTML. And, just as in HTML, you<br />

can nest elements, such as this example of the ItemAttributes element, within the Item<br />

element, which also has elements within it such as the Author element:<br />

<br />

Luke Welling<br />

Laura Thomson<br />

Sams<br />

Book<br />

<strong>PHP</strong> <strong>and</strong> <strong>MySQL</strong> <strong>Web</strong> <strong>Development</strong><br />

There are also some differences from HTML.The first is that each opening tag must<br />

have a closing tag.The exception to this rule is empty elements that open <strong>and</strong> close in a<br />

single tag because they do not enclose any text. If you are familiar with XHTML, you<br />

have seen the tag used in place of for this exact reason. In addition, all elements<br />

must be properly nested.You would probably get away with Text<br />

using an HTML parser, but to be valid XML or XHTML, the tags would need to be<br />

properly nested as Text.<br />

The main difference you will notice between XML <strong>and</strong> HTML is that we seem to be<br />

making up our own tags as we go along! This is the flexibility of XML.You can structure<br />

your documents to match the data that you want to store.You can formalize the<br />

structure of XML documents by writing either a Document Type Definition (DTD) or<br />

an XML Schema. Both of these documents are used to describe the structure of a given

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!