PHP and XML: Use the expat function (3), read PHP and XML: Use the expat function (3), PHP and XML: Use the expat function (3) how to use this class in a PHP script? It is actually very simple. Here is an example: first, the class definition needs to be included in the script require (CLASS_DIR.class.Newsboy.php and XML: Use the expat function (3)
How to use this class in a PHP script? It is actually very simple. Here is an example:
First, the class definition needs to be included in the script.
Require (CLASS_DIR. "class. Newsboy. php ");
Then, we create a class instance and set the file nature to the actual link of our XML document.
$ News = new newsboy ();
$ News-> xml_file = "xml/mynews. xml ";
Then we call the analyzer to analyze the document.
$ News-> parse ();
Then we print html to the screen.
Print ($ news-> html );
In addition, the class must be released at the end of the process.
$ News-> destroy ();
This is all you need to do.
Section
In this short document, we involved the process of using PHP to process XML:
Simple XML document structure
Define simple markup for XML analyzer
Set simple options for XML analyzer
Register a callback function with the XML analyzer
Use XML analyzer using a PHP class
Use the PHP class in another script
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.