(30 points) Using the simpleXML parser, write a php script named
avgpriceSimple.php that reads an xml
file structured like the cdcatalog.xml and produces
an ascii report similar to the one in class where you have the headings
Artist and Avg. Price and for each artist you print the artist's name in
the format "Lastname, Firstname" and then the average price of that artist's
cds. The output should be in alphabetical order by lastname. If two artists
have the same last name it does not matter which one appears first in the
output. You will note that this problem is a bit more complicated than the
one presented in class because 1) the cdcatalog is organized by cd rather than
by artist, and 2) the artist's name is not divided into a first and lastname
for you. To handle the first problem, I suggest you keep two associative
arrays of artists, one for
the number of cds encountered thus far and one for the total value of the
cds. To handle the second problem I suggest that you use a Perl-style regular
expression to separate the first and last names. You may assume that the
first name is a single first name with no whitespace. If there is only one
name, like Smiley or Dr.Hook, then you should assume that it is a firstname.
You should suppress the comma if the artist has no last name (i.e., only the
firstname should be printed).
Once you have finished processing the cd's you can sort one of the
associative arrays by lastname (use an artist's first name if the artist
only has a first name), then iterate through the array,
calculate the average price for each author, and print each author and the
average price for that author's cds.