PHP and XML: using the expat function (3) how to use this class in a PHP script? It is actually very simple. Here is an example: PHP and XML: using 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 ";
Or
$ News-> xml_file = "http://xmldocs.mysite.com/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 above are PHP and XML: Use the expat function (3). For more information, see PHP Chinese website (www.php1.cn )!