Page 1 of 1

XML file into array line by line?

Posted: Wed Feb 20, 2008 3:59 pm
by aquawicket
Hi.. I'm trying to load the contents of an XML file into an array line by line unaltered.. But the output of the array is empty.. It shows the right amount of lines.. just empty data.. I believe the < and >'s are to blame as this method works fine with normal text files. And Ideas...

Code: Select all

 
$file = fopen("file.xml","r");
$a = array();
while(! feof($file)){
    array_push($a, fgets($file) );
}
print_r($a);
 
My xml looks something like this

Code: Select all

 
<?xml version="1.0" encoding="UTF-8"?>
<player showDisplay="yes" showPlaylist="yes" autoStart="random">
<song path="http://www.website.com/Music/song1.mp3" title="song1" />
<song path="http://www.website.com/Music/song2.mp3" title="song2" />
</player>
 

Re: XML file into array line by line?

Posted: Wed Feb 20, 2008 6:19 pm
by John Cartwright
try file()