tailieunhanh - PHP Programming with PEARXML, Data, Dates, Web Services, and Web APIs - Part 5

Tên và dữ liệu. Lái xe này không nên được sử dụng cho các tài liệu có chứa cấu trúc phức tạp được xác định tại thời gian chạy. Tạo tài liệu XML với XML_Serializer Trong khi XML_Serializer là một gói phần mềm để tạo ra các tài liệu XML, nó có một cách tiếp cận hoàn toàn khác nhau từ hai gói XML_Util và XML_FastCreate. Khi làm việc với một trong những gói này, bạn đang tạo thẻ tài liệu bằng thẻ với mỗi cuộc gọi phương pháp. Khi sử dụng XML_Serializer, bạn đang gọi một phương pháp để tạo ra. | Chapter 3 names and data. This driver should not be used for documents that contain complex structures determined at run time. Creating XML Documents with XML_Serializer While XML_Serializer is a package for creating XML documents it takes a totally different approach from the last two packages XML_Util and XML_FastCreate. When working with one of these packages you are creating the document tag by tag with each method call. When using XML_Serializer you are calling one method to create the complete document at once. It will extract the raw information from an array or an object and convert it to an XML document. While this may sound inflexible when compared to the previous approaches XML_Serializer still is one of the most powerful packages when creating XML documents. It can serialize any data that you pass in as an XML document. So it can create an XML-based string representation of any data. Think of it as the XML equivalent of the built-in serialize function which lets you create a string representation of any data be it a deeply nested array or a complex tree of objects. This string representation may then be saved in a file the user session or even a database. PHP also provides an unserialize function to restore the original data from the string representation. In the second part of this chapter you will also learn about the matching XML_Unserializer class which does this for the XML documents created by XML_Serializer. The typical way to work with XML_Serializer follows these steps Include XML_Serializer and create a new instance Configure the instance using options Create the XML document Fetch the document and do whatever you want with it If you are using XML_Serializer in real-life applications it will never get any harder than this. As you only call one method to actually create the XML document you will need to pass all information that should be contained in the XML document to this method. To make life as easy as possible XML_Serializer accepts .

TỪ KHÓA LIÊN QUAN