0% found this document useful (0 votes)
9 views6 pages

XML Excercises

Uploaded by

berhanu Dagne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

XML Excercises

Uploaded by

berhanu Dagne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

XML EXCERCISES

Exercise 1: Create an XML document representing 3 a bookstore. Include the following information for
each book:
- Title
- Author
- Year of publication
- ISBN
- Price
<bookstore>
<book>
<title>Book Title 1</title>
<author>Author 1</author>
<year>2000</year>
<isbn>ISBN 123456789</isbn>
<price>19.99</price>
</book>
<book>
<title>Book Title 2</title>
<author>Author 2</author>
<year>2005</year>
<isbn>ISBN 987654321</isbn>
<price>24.99</price>
</book>
<book>
<title>Book Title 3</title>
<author>Author 3</author>
<year>2010</year>
<isbn>ISBN 456789123</isbn>
<price>14.99</price>
</book>
</bookstore>
Exercise 2: Create an XML document representing 3 customer list. Include the following information for
each customer:
- Name
- Email
- Address (Include street, city, state, and zip code)
<customer_list>
<customer>
<name>John Doe</name>
<email>[email protected]</email>
<address>
<street>123 Main St</street>
<city>City 1</city>
<state>State 1</state>
<zipcode>12345</zipcode>
</address>
</customer>
<customer>
<name>Jane Smith</name>
<email>[email protected]</email>
<address>
<street>456 Elm St</street>
<city>City 2</city>
<state>State 2</state>
<zipcode>67890</zipcode>
</address>
</customer>
<customer>
<name>Bob Johnson</name>
<email>[email protected]</email>
<address>
<street>789 Oak St</street>
<city>City 3</city>
<state>State 3</state>
<zipcode>54321</zipcode>
</address>
</customer>
</customer_list>
Exercise 3: Create an XML document representing 3 a music playlist. Include the following information
for each song:
- Title
- Artist
- Album
- Duration
<playlist>
<song>
<title>Song Title 1</title>
<artist>Artist 1</artist>
<album>Album 1</album>
<duration>3:45</duration>
</song>
<song>
<title>Song Title 2</title>
<artist>Artist 2</artist>
<album>Album 2</album>
<duration>4:20</duration>
</song>
<song>
<title>Song Title 3</title>
<artist>Artist 3</artist>
<album>Album 3</album>
<duration>5:15</duration>
</song>
</playlist>
Exercise 4: Create an XML document representing a student database. Include the following
information for each 3 student:
- Name (Name type=”student”)
- Student ID
- Major
- GPA
<student_database>
<students>
<student1>
<Name type="student">DANIEL ABEBE</Name>
<student_id>001</student_id>
<major>Computer Science</major>
<gpa>3.5</gpa>
</student1>
<student2>
<name>BEMNET ALEMU</name>
<student_id>002</student_id>
<major>Business Administration</major>
<gpa>4.0</gpa>
</student2>
<student3>
<name>Mike Johnson</name>
<student_id>54321</student_id>
<major>Engineering</major>
<gpa>3.2</gpa>
</student3>
</students>
</student_database>
Exercise 5: Create an XML document representing a product catalog. Include the following information
for each product:
- Product ID
- Product Name
- Description
- Price
- Availability
<product_catalog>
<product>
<product_id>1</product_id>
<product_name>Product 1</product_name>
<description>Description of Product 1</description>
<price>19.99</price>
<availability>In Stock</availability>
</product>
<product>
<product_id>2</product_id>
<product_name>Product 2</product_name>
<description>Description of Product 2</description>
<price>24.99</price>
<availability>Out of Stock</availability>
</product>
<product>
<product_id>3</product_id>
<product_name>Product 3</product_name>
<description>Description of Product 3</description>
<price>14.99</price>
<availability>In Stock</availability>
</product>
</product_catalog>
Exercise 6: Create an XML document representing a company's employee directory. Include the following
information for each employee:

- Name
- Employee ID
- Department
- Position
- Email
<employee_directory>
<employee>
<name>John Doe</name>
<employee_id>12345</employee_id>
<department>Marketing</department>
<position>Manager</position>
<email>[email protected]</email>
</employee>
<employee>
<name>Jane Smith</name>
<employee_id>67890</employee_id>
<department>Finance</department>
<position>Accountant</position>
<email>[email protected]</email>
</employee>
<employee>
<name>Bob Johnson</name>
<employee_id>54321</employee_id>
<department>IT</department>
<position>Developer</position>
<email>[email protected]</email>
</employee>
</employee_directory>

Exercise 7: Create an XML document representing a customer order. Include the following information:

- Order ID
- Customer Name
- Order Date
- Product Name
- Quantity
- Total Price
<customer_order>
<order>
<order_id>1001</order_id>
<customer_name>John Doe</customer_name>
<order_date>2024-02-27</order_date>
<product_name>Product 1</product_name>
<quantity>2</quantity>
<total_price>39.98</total_price>
</order>
<order>
<order_id>1002</order_id>
<customer_name>Jane Smith</customer_name>
<order_date>2024-02-28</order_date>
<product_name>Product 2</product_name>
<quantity>1</quantity>
<total_price>24.99</total_price>
</order>
<order>
<order_id>1003</order_id>
<customer_name>Bob Johnson</customer_name>
<order_date>2024-03-01</order_date>
<product_name>Product 3</product_name>
<quantity>3</quantity>
<total_price>44.97</total_price>
</order>
</customer_order>

Exercise 8: Create an XML document representing a COLLEGE. Include the following information for
each Department:

1. DEPARTMENT1
- NAME
- NUMBER (TYPE=”INT”)
- COURSE1 (NAME, NUMBER(TYPE=”CODE”),CREDIT HOUR(TYPE=”Cr_Hr”)
- TEACHER (TNAME(type=”Teacher”)
- COURSE2 (NAME, NUMBER(TYPE=”CODE”),CREDIT HOUR(TYPE=”Cr_Hr”)
- TEACHER (TNAME(TYPE=”Teacher”), TIDNO(TYPE=”IDNO”)
1. DEPARTMENT2
- NAME
- NUMBER
- COURSE1 (NAME, NUMBER(TYPE=”CODE”),CREDIT HOUR(TYPE=”Cr_Hr”)
- TEACHER (TNAME(type=”Teacher”)
- COURSE2 (NAME, NUMBER(TYPE=”CODE”),CREDIT HOUR(TYPE=”Cr_Hr”)
<COLLEGE>
<Department>
<DEPARTMEN1>
<NAME>ICT</NAME>
<NUMBER type="INT">101</NUMBER>
<COURSE1>
<NAME>WEB DESIGN</NAME>
<NUMBER type="CODE">ICT1012</NUMBER>
<Cr_Hr type="Cr_Hr">4</Cr_Hr>
<TEACHER>
<TNAME type="TEACHER">ABEBE</TNAME>
</TEACHER>
</COURSE1>
<COURSE2>
<NAME>PROGRAMMING</NAME>
<NUMBER type="CODE">ICT1212</NUMBER>
<Cr_Hr type="cr_hr">4</Cr_Hr>
<Teacher>
<TNAME type="TEACHER">AYELE</TNAME>
<TIDNO type="IDNO">01</TIDNO>
</COURSE2>
</DEPARTMEN1>
<DEPARTMEN2>
<NAME>CHEMISTRY</NAME>
<NUMBER>102</NUMBER>
<COURSE1>
<NAME>ORGANIC CHEMISTRY</NAME>
<NUMBER type="CODE">ICT1012</NUMBER>
<Cr_Hr type="Cr_Hr">4</Cr_Hr>
</COURSE1>
<COURSE2>
<NAME>INORGANIC CHEMISTRY</NAME>
<NUMBER type="CODE">CHEM1212</NUMBER>
<Cr_Hr type="cr_hr">4</Cr_Hr>
</COURSE2>
</DEPARTMEN2>
</department>
</COLLEGE>

You might also like