PHP and XML: Use the expat function (1) _ PHP Tutorial

Source: Internet
Author: User
PHP and XML: Use the expat function (1 ). PHP and XML: using the expat function (1) ExtensibleMarkupLanguage is clearly something that most developers will want to add to their toolbox. XML is a PHP and XML type: Use the expat function (1)

Extensible Markup Language is clearly something that most developers will want to add to their toolbox. XML is a W3C standard. it is open, language-neutral, API-neutral, stream, text, and human-readable, it is also a way to bring structured data to the web. XML is a subset of SGML. it is not an identity language, but it allows the authors to define their own identity language to maintain better consistency with hierarchical data.

Now, using PHP to analyze XML documents is not a very deep topic I have seen on the web and other places. Some useful information for XML analysis functions has been provided in the PHP manual, but this seems to be 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 part of my effort to change this situation.

I will lead the reader to experience a fairly simple XML application, which is the implementation of the news system for my website. I did use this application on my website, and now it works well. If you like it, you can use it freely. Okay, let's get started!

To make XML analysis functions effective in PHP, you need a module that supports XML on your web server. This means that you may have to re-compile your module to support XML. For more information, see here. XML analysis functions are actually included in a SAX analyzer expat, which provides simple functions about XML. Another analyzer is DOM analyzer, which is easier to use. one example of this analyzer is Microsoft's MSXML Analyzer component, it allows programmers to manipulate a tree-like object to process nodes and elements. The expat analyzer (or any SAX analyzer) allows you to analyze an XML document by specifying a callback function for different tag types during XML document analysis. When the analyzer analyzes your XML document and encounters a tag, it will call your function and your function will process the specific tag before it continues to run. You can think of it as an event-driven method.

Let's take a look at an XML document that uses the 'newsboy 'class for analysis.



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







03/31/2000
Sooo Busy!

I haven't posted anything here 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 record set in a session
Variable after
Doing an SQL query. The neat part is that an XML doc is stored in the session variable
An when paging
Through the results (often near 1000 !) The script displays 50 results at a time from
XML doc in
Session variable instead of doing another query against the database. It takes a BIG load
Off of
Database server.




03/25/2000
NewsBoy Class

Converted Newsboy to a PHP class to allow better publish action (as far as PHP allows .)

Guess that means this is version 0.02 ?!
Newsboy will 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. You may ask, "" What the heck is it ?! ".

Well it's a simple news system for web-sites, written in PHP, that 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 will be loads of improvements as
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 particle 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 has to play American football with
Bad guys.
The official website for the movie is> here


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

Http://www.bkjia.com/PHPjc/316798.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/316798.htmlTechArticlePHP and XML: using the expat function (I) the Extensible Markup Language is clearly something that most developers will want to add to their toolbox. XML is...

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.