tailieunhanh - Object-Oriented Programming with PHP 5 phần 9

Khả năng tạo kết nối nén Khả năng kết nối qua SSL Hỗ trợ Hỗ trợ báo cáo chuẩn bị cho thủ tục lưu trữ (SP) Hỗ trợ để nhân rộng tốt hơn và giao dịch và làm thế nào để sử dụng một số các tính năng này tiên tiến Hãy xem ví dụ sau:(tốt, có một vài phương pháp thủ tục, nhưng tổng thể nó hoàn toàn, OO). | Cooking XML with OOP So you see that XML documents do have a small declaration at the top which details the character set of the document. This is useful if you are storing Unicode texts. In XML you must close the tags as you start it. XML is strict than HTML you must follow the conventions. Let s look at another example where there are some special symbols in the data xml version encoding ISO-8859-1 emails email from nowhere@ from to unknown@ to subject there is no subject subject body CDATA is it a body oh ya with some texts symbols body email emails This means you have to enclose all the strings containing special characters with CDATA. Again each entity may have some attributes with it. For example consider the following XML where we describe the properties of a student student age 17 class 11 title Mr. Ozniak student In the above example there are three attributes to this student tag age class and title. Using PHP we can easily manipulate them too. In the coming sections we will learn how to parse XML documents or how to create XML documents on the fly. Introduction to SimpleXML In PHP4 there were two ways to parse XML documents and these are also available in PHP5. One is parsing documents via SAX which is a standard and another one is DOM. But it takes quite a long time to parse XML documents using SAX and it also needs quite a long time for you to write the code. In PHP5 a new API has been introduced to easily parse XML documents. This was named SimpleXML API. Using SimpleXML API you can turn your XML documents into an array. Each node will be converted to an accessible form for easy parsing. 196 Chapter 8 Parsing Documents In this section we will learn how to parse basic XML documents using SimpleXML. Let s take a breath and start. str END emails email from nowhere@ from to unknown@ to subject there is no subject subject body CDATA is it a body oh ya with some texts symbols body email emails END sxml .

TỪ KHÓA LIÊN QUAN