XML file into array line by line?
Posted: Wed Feb 20, 2008 3:59 pm
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...
My xml looks something like this
Code: Select all
$file = fopen("file.xml","r");
$a = array();
while(! feof($file)){
array_push($a, fgets($file) );
}
print_r($a);
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>