#native_company# #native_desc#
#native_cta#

PHP and XML: Using the expat functions Page 5

By Justin Grant
on July 30, 2000

How do you use this class in a PHP script ?
It’s very simple actually.
Here is an example:
First the class definition needs to be included in the script:
require (CLASS_DIR.”class.Newsboy.php”);
Then, we create an instance of the class and set the file property to the actual location 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 parse method to parse the document:
$news->parse();
Then we print out the html to the browser:
print ($news->html);
And, lastly when done with the object we must destroy it:
$news->destroy();
And that’s really all there is to it !!!