XML for PHP Developer part 2nd: Advanced XML parsing technology

Source: Internet
Author: User
Keywords XML for PHP Developer part 2nd: Advanced XML parsing technology

Brief introduction

PHP5 provides more XML (standardization is getting closer) parsing techniques. James Clark's Expat SAX parser (now based on the libxml (standardized getting closer) 2) is no longer the only fully functional parser. Parsing is often required using a fully compliant DOM parser. Regardless of whether the Simplexml described in part 1th (see Resources) or the simpler and faster XML (standardization is getting closer) than SAX, Reader provides additional parsing methods. All of this XML (standardization is getting closer) is now based on the libxml of the GNOME Project (the standardization is getting closer) 2 libraries. This unified library takes into account the interoperability between the different extensions. This article describes the parsing techniques for PHP5 XML (which is getting closer to standardization), especially for large, complex XML (which is getting closer to standardization). It also introduces some background knowledge about parsing techniques, which method is best suited to what type of XML (standardization is getting closer) to the document, and what criteria should be used if the choice is to be made.

Simplexml (standardization getting closer)

The 1th part introduces the basic information of XML (standardization is getting closer), mainly introduces the simple, entry-level application programming Interface (application Programming Interfaces,api). By example, for documents that deal with simple, predictable, and small XML (which is getting closer to standardization), Simplexml (standardization is getting closer) (and, when necessary, in combination with the Document Object Model (DOM)) is an ideal choice.

XML (standardization getting closer) and PHP5

Extensible Markup Language (extensible Markup language,xml) is not only considered as a markup language, but also a text-based data storage format that provides a text-based approach to the application and description of information in a tree-like structure.

PHP5 provides some new and rewritten XML (normalization is getting closer) parsing extensions. This includes loading the entire XML (standardized getting closer) document into in-memory Simplexml (normalization is getting closer), DOM, and XSLT handlers. There is also a simple API for XML (the standardization is getting closer) (SAX) and XML (standardization getting closer) Reader that is loaded into memory every time the XML (standardization is getting closer) is part of the document. The functionality of SAX and no change in PHP4, but no longer based on the expat library, instead of using the Libxml (standardization is getting closer) 2 libraries. If you are familiar with the DOM in other languages, it is much simpler to use DOM programming in PHP5 than in previous versions.

XML (standardization getting closer) parsing basics

Parsing XML (standardization is getting closer) has two basic ways: trees and streams. The tree parsing method needs to load the entire XML (normalized closer) document into memory. The tree file structure allows random access to document elements and edit XML (normalization is getting closer). Examples of tree-type parsing include DOM and Simplexml (standardization is getting closer). These parsers share the tree structure in memory in a different but interoperable format. Unlike tree parsing, stream parsing does not require the entire document to be loaded into memory. The flow in this stream is similar to the flow in streaming audio. Its purpose and purpose are the same, that is, each time a small amount of data is submitted to conserve bandwidth and memory. In stream parsing, only the nodes that are currently resolved can be accessed, and XML (normalization is getting closer) is not editable as a document. Examples of stream parsers include XML (standardization getting closer) to Reader and SAX.

12 3 4 5 6 Next
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.