0% found this document useful (0 votes)
69 views5 pages

Assigment 6 - CS UP

This document provides an assignment on XML for a web programming course. It includes 4 tasks: 1) Create an XML document describing exercises with a root element of <exercises>; 2) Create an XML document describing a person with elements such as <name>, <occupation>, etc.; 3) Draw a tree representing the person XML document; 4) Create an XML file called programOfStudy.xml to capture a student's planned courses over two semesters, with elements such as <generalEducation>, <core>, <majorCourse>. Sample solutions are provided for each task.

Uploaded by

cr rcr
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)
69 views5 pages

Assigment 6 - CS UP

This document provides an assignment on XML for a web programming course. It includes 4 tasks: 1) Create an XML document describing exercises with a root element of <exercises>; 2) Create an XML document describing a person with elements such as <name>, <occupation>, etc.; 3) Draw a tree representing the person XML document; 4) Create an XML file called programOfStudy.xml to capture a student's planned courses over two semesters, with elements such as <generalEducation>, <core>, <majorCourse>. Sample solutions are provided for each task.

Uploaded by

cr rcr
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/ 5

Assignment Unit 6

Programming Assignment Unit 6 – XML

CS 2205 - Web Programming 1 - AY2023-T1

Dr. Tina Esther Trueman (Instructor)

October 10, 2022

1
Assignment Unit 6

<?xml version="1.0"
encoding="ISO-8859-1" ?>
<exercise>
<date>12-24-2017</date>
<item1>Read About
XML</item1>
<item2>Practice
XML</item2>
</exercise>
1. Write an XML document describing the exercises in this document: the root element is
<exercises>. The root has an attribute number that has value 1. The root element has three child
elements; <date> that contains as text the date of the exercise, and two <item> elements for
the first two exercises (1--2). Write some text in the <item> elements.

SOLUTION:

<?xml version="1.0" encoding="UTF-8"?>

<exercise number="1">

<date>10 October 2022</date>

<item> Exercise 1: Write an XML document describing the exercises in this document</item>

<item> Exercise 2: Write an XML document describing a person</item>

</exercise>

2
Assignment Unit 6

2. Write an XML document describing a person: name, occupation, address and hobbies. Please do
not use your own information, you can use fake data.  Decide on suitable element names and
nesting. Check your document for well-formedness

SOLUTION:

<?xml version="1.0" encoding="UTF-8"?>

<person>

<name>

<firstname>Hanny</firstname>

<lastname>Morison</lastname>

</name>

<occupation>Singer</occupation>

<address>

<street>23/b Via Antonio</street>

<city>Santa Lucia Di Piave</city>

<country>Italy</country>

</address>

<hobbies>

<hobby>Singing</hobby>

<hobby>Dancing</hobby>

</hobbies>

</person>

3. Draw a tree that represents the XML document you created in task 2.

SOLUTION:

3
Assignment Unit 6

Person

name occupation address hobbies

firstname lastname street city country hobby hobby

4. Using books.xml as a model, create a small xml file for a student's program of study form called
programOfStudy.xml. It should capture the following data:

 In the Fall 2008 semester the student plans to take two classes to satisfy her General Education
requirements, PHIL 101 to satisfy Goal 8 and ECON 201 to satisfy Goal 11. She also has to take
one core course, MGT 217, and two major courses, CIS 120 and CIS 403.

 In the Spring 2009 semester she plans to take two additional core courses, MGT 261 and MKTG
325, as well as three major courses, CIS 220, CIS 407, and CIS 490.

SOLUTION:

<?xml version="1.0" encoding="UTF-8"?>

<studyprogram>

<program semester="Fall" year="2008">

<generalEducation>

<course1>PHIL 101</course1>

<goal1>8</goal1>

<course2>ECON 201</course2>

<goal2>11</goal2>

</generalEducation>

<core>

<course1>MGT 217</course1>

</core>

4
Assignment Unit 6

<majorCourse>

<course1>CIS 120</course1>

<course2>CIS 403</course2>

</majorCourse>

</program>

<program semester="Spring" year="2009">

<core>

<course1>MGT 261</course1>

<course2>MKTG 325</course2>

</core>

<majorCourse>

<course1>CIS 220</course1>

<course2>CIS 407</course2>

<course3>CIS 490</course3>

</majorCourse>

</program>

</studyprogram>

Reference:
w3schools. (n.d.). XML tutorial. Retrieved from http://www.w3schools.com/xml/default.asp

You might also like