|
Helping ordinary people create extraordinary websites! |
Parsing XML using PHP4By Burhan Khalid2005-08-16
Starting up the parser Now that the parser is setup and configured, we are ready to feed it our XML file and let it parse the information. This is the complicated part of the program, so extra attention is requested. The first step is to open the xml file : PHP: This simple code will check to see if our program can open the file or not. It will quit with an appropriate message if it cannot. Once the file is open, we must read it and feed it to the XML parser. One thing we are going to do before we send the file to the XML parser is we are going to get rid of any whitespace using a regular expression and the eregi_replace function : PHP:
Lets step through this code :
Once we have verified that our parser is working properly, we are ready to actually do something with the data. Tutorial Pages: » Parsing XML using PHP4 » XML File Structure » Creating our XML File » Parsing with PHP » Creating our Parser » Setting up tag handlers » Setting up content (data) handlers » Starting up the parser » Creating the gallery © 2004-2005 Burhan Khalid |
|