Given this xml file, please help me complete the following: This XML document co
ID: 664760 • Letter: G
Question
Given this xml file, please help me complete the following:
This XML document contains records for CDs. The root element is CATALOG and contains a series of CD elements, each of which has a number of child elements such as TITLE, PRICE and so on.
Write a program that will read the file and print out the following information with an appropriate message:
The total number of CDs in the file and the total price of purchasing one of each.
The minimum, maximum, and average price for the CDs in the file.
The total number of CDs released in the year 1990.
Print the names of all artists who are from America (USA).
Use list comprehensions to minimize the code required in parts a – d.
Should be in python, with appropriately named variables and using list comprehensions to minimize the code.
Link to the xml file:
https://drive.google.com/file/d/0B5FX84Uyz9fjOGhHQl9RdHFuVlU/view
Explanation / Answer
#!/usr/bin/perl -wT use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict; print header; print start_html("Results"); # first print the mail message... $ENV{PATH} = "/usr/sbin"; open (MAIL, "|/usr/sbin/sendmail -oi -t -odq") or &dienice("Can't fork for sendmail: $! "); print MAIL "To: recipient@cgi101.com "; print MAIL "From: nobody@cgi101.com "; print MAIL "Subject: Form Data "; foreach my $p (param()) { print MAIL "$p = ", param($p), " "; } close(MAIL); # now write (append) to the file open(OUT, ">>guestbook.txt") or &dienice("Couldn't open output file: $!"); foreach my $p (param()) { print OUT param($p), "|"; } print OUT " "; close(OUT); printRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.