tailieunhanh - Pro PHP Patterns, Frameworks, Testing and more phần 3
từ SimpleXML chính thức Document Object Model (DOM) tạo ra. Tuy nhiên, các tùy chọn này có nhiều hạn chế, và tại những thời điểm, các API bực bội và khó hiểu Lớp XMLWriter được giới thiệu trong PHP 6 để cung cấp một phương pháp đơn giản, đơn giản, và dễ dàng sử dụng để tạo tài liệu XML. | CHAPTER 5 WHAT S NEW IN PHP 6 51 from SimpleXML to full-fledged Document Object Model DOM creation. However these options have many limitations and at times frustrating and confusing APIs The XMLWriter class is being introduced in PHP 6 to provide a simple straightforward and easy-to-use method for XML document creation. The API for this component has not yet been fully developed and it is likely to change. You can find the latest reference information at http xmlwriter. Listing 5-15 is intended as a demonstration of how the API will eventually come together but is not intended to be used as exact syntax. This listing builds a basic XHTML document for the output stream. Listing 5-15. A Sample XHTML Document php Instantiate and set indentation options xml new XMLWriter xml- openURI php output xml- setIndentString xml- setIndent true Start the document and set the DTD xml- startDocument UTF-8 xml- startDtd html - W3C DTD XHTML Strict ZEN http TR xhtml1 DTD xml- endDtd Create the HTML document xml- startElement html xml- writeAttribute xmlns http l999 xhtml xml- writeAttribute xml lang en xml- writeAttribute lang en xml- startElement head xml- writeElement title An example XHTML document. xml- endElement xml- startElement body xml- writeElement p Hello World xml- startElement p xml- text This paragraph contains an inline xml- startElement a xml- writeAttribute href http xml- text link. xml- endElement a xml- endElement p 52 CHAPTER 5 WHAT S NEW IN PHP 6 xml- endElement body xml- endElement html xml- endDocument xml- flush xml version encoding UTF-8 DOCTYPE html PUBLIC - W3C DTD XHTML Strict ZEN http TR xhtml1 DTD html xmlns http 1999 xhtml xml lang en lang en head title An example XHTML document. title head body p Hello World p p This paragraph contains an inline a href http link. a p body html Just the Facts This chapter started
đang nạp các trang xem trước