Expat PHP and XML: Using the Expat function one

Source: Internet
Author: User
PHP and XML: Using the Expat function (i)
The Extensible Identity language (extensible Markup Language) is clearly something that most developers will want to add to their toolbox. XML is a world-class standard that is open, language neutral, API neutral, streaming, textual, human readable, and a way to bring structured data to the Web. XML, a subset of SGML itself, is not an identity language in itself, but it allows authors to define their own identity language in order to maintain better consistency with hierarchical data.
Now, parsing XML documents with PHP is no longer a deeply covered topic as I've seen in the Web and elsewhere. Some useful information about XML parsing functions has been provided in the PHP manual, but this looks like all the information I can find. Other languages seem to have more information and working examples of XML than PHP, so in this article I will try to make a part of my effort to change this situation.
I will lead the reader through a fairly simple XML application that is the implementation of the news system for my site. I did use this app on my website and now it works very well. You are free to use it if you like. All right, let's get started!
In order for the XML parsing function to work in PHP, you need a module that supports XML on your Web server. This means that you will probably have to recompile your module so that it can support XML, please refer here to see how to do more information. XML parsing functions are now really contained in a SAX parser expat, which provides a simple function of XML. Another parser is the DOM parser, which is easier to use, and one example of this is the Microsoft MSXML Parser component, which allows programmers to manipulate a tree-style object to handle nodes and elements. The expat parser (or any SAX parser) allows you to parse an XML document by specifying a callback function for different tag types when parsing an XML document. When the parser starts parsing your XML document and encounters a tag, it will call your function and the specific token is processed by your function before proceeding to the next step. You can think of it as an event-driven approach.
Let's look at an XML document that is parsed using the ' Newsboy ' class
--------------------------------------------------------------------------------
Mynews.xml
03/31/2000
Sooo Busy!
I Haven ' t posted anything here for a while now as I had been busy with work (has to pay those
bills!).
I have just finished a neat little script that stores a all record set in a session
Variable after
Doing an SQL query. The neat part is a XML doc is stored in the session variable
When paging
Through the results (often near 1000!) the script displays in a time from the
XML Doc in the
Session variable instead of doing another query against the database. It takes a BIG load
Off of the
Database server.
03/25/2000
Newsboy Class
Converted Newsboy to a PHP class to allow better abstraction (as far as PHP allows.)
Guess that means-is version 0.02?!
Newsboy'll has a section of it's own soon on how to use and customize the class.
03/24/2000
Newsboy is up!
I have just finished newsboy v0.01!!!
It looks quite promising. You could ask, "What's the heck is it?!".
Well it's a simple news system for Web-sites, written in PHP, so makes use of XML
For
The news data format allowing easy updating and portability between platforms.
It uses the built in expat parser for Apache.
This is just the very first version and there'll be loads of improvements as the
Project progresses.
03/24/2000
Romeo Must Die
Saw a really cool movie today at Mann called ' Romeo Must Die '
Nice fight scenes for a typical kung-fu movie with some ' Matrix ' style effects.
One particular cool effect was the ' X-ray Vision ' effect that occured in various
Fight scenes.
The hero, played by Jet Li, strikes a bad guy and you can see the bone in his arm
Crack, in X-ray vision.
There were some funny scenes too when Jet have to play American football with the
Bad guys.
The official website for the movie are > here
Romeomustdie.net/images/image15.jpg "width=300 >

The above describes the expat PHP and XML: Using the expat function one, including the expat aspect of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.