Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA XML and web service homework Complete the following programs. Send them to

ID: 3825078 • Letter: J

Question

JAVA

XML and web service homework

Complete the following programs.

Send them to Blackboard

Baseball - again

Build an XML document using last week’s stats file.

Read the new XML document into a list

Calculate and display the batting average for each player

Web Service

Create a Java application [i]that uses the GetAtomicNumber web services from http://www.webservicex.net/New/Home/ServiceDetail/19

Requirements

When a user selects an element name, the screen draws up the element as shown on the periodic table. The information for that element will appear as shown below. I want a box output for the atomic number, Symbol, and Atomic Weight. If desired, you can display the other information

Make sure you make the form look especially good. Have titles, color, …

My output is on the second page. It resembles an entry on a periodic table of the elements.

Post completed work to Blackboard when finished.

Bonus

Use the GetAtoms webservice to populate a drop-down box with all the Element names

Example Output for Iron

[i] (old link) http://www.webservicex.net/WS/WSDetails.aspx?WSID=19&CATID=7.

Explanation / Answer

XML means extensible mark up language.

Here I am providing the sample code for xml generation using sample java code

The method name is xmlGeneration.It expands JAXBException and IOException

It consists of several steps.

- Create plain old java object classes.

-make JAXBContext object.

-make marshall objects.

-make contents

-call the necessary marshal call.

public void xmlGeneration() throws JAXBException, IOException {

    Sample sample = new Sample ();

    XmlData data = new XmlData();

    XmlData data2 = new XmlData();

    data.setName ("111");

    data.setType("222");

    data.setValue("333");

    data2.getData().add(data);

   File f = new File("thomas.xml");

    JAXBContext context= JAXBContext.newInstance("com..xmlgenerator.model.generateXml");

    Marshaller jaxbMarshaller = context.createMarshaller();

    jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

    jaxbMarshaller.marshal(sample, f);

    jaxbMarshaller.marshal(sample, System.out);

}

Here I am describing how we can read an xml using java code

The steps for reading xml file using java is

-Import package of XML

      -Create a DocumentBuilder.

      -Create a Document from a file or stream.

         -Extract the root data.

          -Check the values

        - check the sub values