PHP and XML: Using the Expat function (a) _php Foundation

Source: Internet
Author: User
Tags php class
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 standard for the world of public information, it is open, language neutral, API neutral, streaming, text, human readable, and is a way to bring structured data to the Web. XML is a subset of SGML, which 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 in PHP is no longer a covered topic like I've seen on the Web and elsewhere. The PHP manual already provides some useful information about XML parsing functions, but this looks like all the information I can find. Other languages seem to have more XML information and working examples than PHP, so in this article I will try to make a part of my effort to change that.

I will lead the reader through a fairly simple application of XML, which is the implementation of the news system for my site. I did use this application on my site and now it works well. If you like, you are free to use it. All right, let's get started!

To make the XML parsing function effective in PHP, you need an XML-enabled module on your Web server. This means that you will probably have to recompile your module so that you can support XML, please refer here to see how to do more information. The XML parsing function is now truly contained in a SAX parser expat, which provides a simple function of XML. Another parser is the DOM parser, which is easier to use, with an example of Microsoft's MSXML Analyzer component, which allows programmers to manipulate nodes and elements by manipulating a tree-style object. The Expat Analyzer (or any SAX parser) allows you to analyze an XML document by specifying a callback function for different tag types when parsing the XML document. When the parser starts parsing your XML document and encounters a tag, it calls your function and processes the specific tags by your function before proceeding down. You can think of it as an event-driven approach.

Let's look at an XML document that uses the ' Newsboy ' class to parse



--------------------------------------------------------------------------------
Mynews.xml







03/31/2000
Sooo Busy!

I haven ' t posted anything for a while now as I have been busy with work (have to pay those
bills!).
I have just finished a neat little script that stores a complete the record set in a
Variable after
Doing an SQL query. The neat part is this XML doc is stored into the session variable
A When paging
Through the results (often near 1000!) the script displays results at a
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 this is version 0.02?!
Newsboy would have 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. Ask, "What the heck is it?!".

It ' s a simple news system for Web-sites, written in PHP, which 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 and there'll be loads of improvements as the
Project progresses.




03/24/2000
Romeo must Die

Saw a really cool movie this at Mann called ' Romeo must Die '
Nice fight scenes for a typical kung-fu movie with some ' Matrix ' style effects.

One particular cool effect is the ' X-Ray Vision ' effect that occured in various
Fight scenes.
The hero, played by Jet Li, strikes A, and you can-the bone in his arm
Crack, in X-RAY vision.
There were some funny scenes too when Jet has to play American football with the
Bad guys.
The official website for the movie is <a href= ' http://www.romeo-must-die.com '
> Here </A>


Romeomustdie.net/images/image15.jpg "width=300 >

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.