TAILIEUCHUNG - PHP Programming with PEARXML, Data, Dates, Web Services, and Web APIs - Part 6

Xử lý này là khá đơn giản: Nếu dữ liệu chỉ bao gồm các khoảng trắng, nó sẽ bị bỏ qua, nếu không chúng tôi thêm nó vào các tài sản currentData $. Việc xử lý cuối cùng còn lại để thực hiện các phương pháp xử lý thẻ đóng: / ** * Xử lý đóng thẻ * * @ param nguồn tài nguyên phân tích cú pháp * @ param string thẻ tên * / chức năng công cộng endHandler (phân tích cú pháp, $ name) | Chapter 3 This handler is quite simple If the data consists only of whitespace it is ignored otherwise we append it to the currentData property. The last handler left to implement is the method handling closing tags handle closing tags @param resource parser resource @param string tag name public function endHandler parser name switch name case configuration break end of section clear the current section case section this- currentSection null break default if this- currentSection null return store the current data in the configuration this- sections this- currentSection name trim this- currentData break Again the closing configuration tag is ignored as it is only used as a container for the document. If we find a closing section tag we just reset the currentSection property as we are not inside a section anymore. Any other tag will be treated as a configuration directive and the text that has been found inside this tag and which we stored in the currentData property will be used as the value for this directive. So we store this value in the sections array using the name of the current section and the name of the closing tag except when the current section is null. Accessing the Configuration Options Last we need to add a method to access the data collected while parsing the XML document 139 Working with XML Fetch a configuration option @param string name of the section @param string name of the option return mixed configuration option or false if not set public function getConfigurationOption section value if isset this- sections section return false if isset this- sections section value return false return this- sections section value This method accepts the name of a section as well as the name of a configuration option. It will check whether the section and the option have been defined in the XML document and return its value. Otherwise it will return null. Finally our configuration reader is ready to use config new ConfigReader online result config- .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.