XML extract from site.

User Generated

peevbf

Programming

Description

For this assignment you will model and process an XML document   ttp://free1.ed.gov/xml/gemexport.xml) containing a set of teaching and learning resources produced by the Department of Education (http://www.ed.gov/)

You will need to extract the following data from each of <resource> elements in the document:
 

  • title

  • description

  • url

  • the list of subjects, both
         the categories and subcategories.

You will need to define an appropriate set of classes that model
the structure of the XML document using the approach described in the content.
You only need to model the subset of information that needs to be collected. It
will require more than one class, however.

Further, you must create a class, ResourceImporter, which has exactly
two operations:

public class ResourceImporter {

  private static
Document loadXMLDocument(String documentLocation) { ... }

  public static
Resources importResourcesFromXML(String documentLocation) { ... }


}

where Resources is the class that represents the element <root> in the resource
document. Technically, if you apply the method for mapping an XML structure to a
set of classes, the name of the class should be Root but Resources is more meaningful. The class should load and parse the resources XML document, similar to how TopTracksImporter worked in the
LastFM example.

You must also have a class T_Resources which contains the  main(). It must be the only file that contains a main(). It will use ResourceImporter to load the document and then use the returned Resources object to produce formatted output. Given a structure that looks like the following (note that
the irrelevant parts of the structure have been stripped)

<resource>

  <title>Ben's
Guide to the U.S. Government for Kids</title>

 
<description>Help's K-12 students learn...</description>

  <identifier>

 
<url>http://bensguide.gpo.gov/</url>

  </identifier>

  <subjects>

  <subject>

 
<category>Government</category>

 
<subcategory>Elections</subcategory>

  </subject>

  <subject>

 
<category>Government</category>

 
<subcategory>Other</subcategory>

  </subject>

  <subject>

 
<category>Government</category>

 
<subcategory>Congress</subcategory>

  </subject>

  </subjects>

 

</resource>

 

The output should look like

 

Ben's Guide to the U.S. Government for Kids'

 

http://bensguide.gpo.gov

 

  Government ::
Elections

 

  Government :: Other

 

  Government :: Congress

 

A blank line should appear between the outputs of the different
resources.

Submission Requirements

Your submission for this assignment will consist of a single zip
file that contains the Java source code files (no .class files!). The files
should not be nested in another folder. The Java classes cannot depend on
anything more than each other and the standard Java libraries.

Each class you define should be contained in its own .java file. Each file requires a header at the top of the file of the form

To do this, we will use the
Document Object Model (DOM). The DOM is an API maintained by the World Wide Web
Consortium (W3C). An API just tells what's available and how things work. There
needs to be an implementation of the API and, conveniently, Java provides one.




User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
Great! Studypool always delivers quality work.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags