XML for PHP developers Part 1: advanced XML parsing technology

Source: Internet
Author: User
Introduction PHP5 provides more xml (standardization is getting closer and closer) Parsing Technologies. The ExpatSAX parser of JamesClark (now based on libxml (standardization is getting closer and closer) 2) is no longer the only fully functional parser. It is often necessary to use a DOM parser that fully complies with W3C standards for parsing. Whether Simplexml (standardization is getting closer) introduced in part 1 (see references) or introduction

PHP5 provides more xml (standardization is getting closer and closer) Parsing Technologies. James Clark's Expat SAX parser (now based on libxml (standardization is getting closer and closer) 2) is no longer the only fully functional parser. It is often necessary to use a DOM parser that fully complies with W3C standards for parsing. Whether Simplexml (standardization is getting closer and closer) introduced in part 1 (see references) or xml (standardization is getting closer and closer) reader provides other parsing methods. All these xml (standardization is getting closer and closer) extensions are now based on libxml (standardization is getting closer and closer) 2 libraries of the GNOME project. This unified library considers the interoperability between different extensions. This article will introduce the parsing technology of PHP5 xml (standardization is getting closer and closer), especially the parsing of large and complex xml (standardization is getting closer and closer) documents. I also introduced some background knowledge about parsing technology, the method that is best suited to what type of xml (standardization is getting closer and closer) documentation, and the criteria that should be used to make a choice.

Simplexml (standardization is getting closer and closer)

Part 1 introduces the basic information of xml (standardization is getting closer and closer), and mainly introduces simple and entry-level Application Programming Interfaces (APIs ). Examples show that Simplexml (standardization is getting closer and closer) (when necessary, with the Document Object Model (DOM) for simple, predictable, and small xml documents (standardization is getting closer and closer)) is an ideal choice.

Xml (standardization is getting closer and closer) and PHP5

Extensible Markup Language (xml) is not only a Markup Language, but also a text-based data storage format, it provides a text-based method to apply and describe the tree structure of information.

PHP5 provides some new and re-compiled xml (standardization is getting closer and closer) parsing extensions. These include loading the entire xml (standardization is getting closer and closer) document into Simplexml (standardization is getting closer and closer) in the memory, DOM and XSLT processing programs. There are also some Simple API for xml (standardization is getting closer and closer) and xml (standardization is getting closer and closer) loaded into the memory each time) reader. The functions of SAX have not changed in PHP4, but instead of using libxml (standardized) Library 2 based on the expat library. If you are familiar with DOM in other languages, it is much easier to use DOM Programming in PHP5 than in earlier versions.

Xml (standardization is getting closer and closer) parsing basics

There are two basic methods for parsing xml (standardization is getting closer and closer): Tree and stream. The tree parsing method needs to load the entire xml (standardization is getting closer and closer) document into the memory. The tree file structure allows random access to document elements and xml editing (standardization is getting closer and closer ). Examples of tree-based parsing include DOM and Simplexml (standardization is getting closer and closer ). These resolvers share the tree structure in different but interoperable formats in the memory. Different from the tree parsing method, stream parsing does not need to load the entire document into the memory. The stream here is similar to the stream in stream audio. The purpose and purpose are the same, that is, a small amount of data is submitted each time to save bandwidth and memory. In stream parsing, you can only access the nodes currently parsed, and cannot edit xml (standardization is getting closer and closer) as a document. Examples of stream parser include xml (standardization is getting closer and closer) Reader and SAX.

12 3 4 5 6 Next Page

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.