> developer > dnu > courses > Web Services page 11
Web Services
April 2003
DeveloperNet University Course
Reader Rating    from ratings rate this article
View an eBook Version of this course - LARGE FILE! Send this page to a friend

Exercises

Exercise 1: Write a Simple XML Document

In this exercises, you will create an XML document with the data provided below. This skill is important as you plan for the exchange of data in your Web Service. As you write an XML document, keep in mind that the element names should be descriptive of the data they describe and short.

Create Java Programs
Written by: Jeff Fischer
Topic: Beginning Java
ISBN: 1-555-2555

Creating Better Java Programs
Written by: Jeff Fischer
Topic: Intermediate Java
ISBN: 1-555-2556

Creating the Best Java Programs
Written by: Jeff Fischer
Topic: Advanced Java
ISBN: 1-555-2557

Creating Java Web Services
Written by: Jeff Fischer
Topic: Web Services
ISBN: 1-555-2558

  1. Open Notepad or some other text editor.

  2. Type in the XML declaration first.


<?xml version="1.0" encoding="ISO-8859-1"?>

  1. Analyze the data that you need to represent in the XML document and decide what it is you are trying to represent.

  2. Since we are going to represent data from a book catalog, let's use catalog as the name for the root element of the XML document.

  3. Type <catalog>

  4. Since the data we have is for a book, we will use book for the child element name.

  5. Type <book>.

  6. Type <title>Create Java Programs</title>

  7. Type <author>Jeff Fischer</author>.

  8. Type <topic>Beginning Java</topic>.

  9. Type <isbn>1-555-2555</isbn>.

  10. Type </book>.

  11. Repeat steps 7-11 for each book.

  12. Type </catalog>.

  13. Save the document as catalog.xml.

You should now be able to open the document in Internet Explorer and see the structure of the document.

Previous Contents Next
download sample file