Hello, I'm new to PHP and I have a question.
I'm working with an xml file that shows flight delays (http://www.flightstats.com/go/rss/airportdelays.do).
In PHP, I need to make a variable that displays the total number of items in the flight delay xml file (i.e. the total number of current delays). I don't need to parse any of the information within the items--I just need code that will look at the XML file and make a variable that shows how many there are.
So for example, if there were two items in the XML file, the variable would equal 2, and I could display something like "Total Reported Delays=2".
Is there any simple way to do this? Will I need some kind of external file to parse the XML, or can PHP handle this kind of thing itself?
Thanks in advance,
Tom
Display number of items in xml file
Moderator: General Moderators
-
Tomcat7194
- Forum Commoner
- Posts: 48
- Joined: Mon Jul 31, 2006 1:34 pm
Just grab the xml file as a string, and use substr_count to count the instances of whatever tag you are using to hold a delay.
-
Tomcat7194
- Forum Commoner
- Posts: 48
- Joined: Mon Jul 31, 2006 1:34 pm
simplexml_load_file
For more information about how to use it: http://www.devshed.com/c/a/PHP/Loading- ... -in-PHP-5/
For more information about how to use it: http://www.devshed.com/c/a/PHP/Loading- ... -in-PHP-5/
-
Tomcat7194
- Forum Commoner
- Posts: 48
- Joined: Mon Jul 31, 2006 1:34 pm