Generate Well-formed XML document 2

Question:

Generate XML for the given scenario

   XYZ school wants to store the details of student and staff in a xml file. The following scenario helps in designing the XML document.

  persons will be the root tag. persons will have the entry of each person with name, age, gender, address. A person can be either a student or staff. student will have rollno, standard and section. If staff, then staffid and subject. Every person must have an address with the following entry- doorno,street,city and state.

Code:

person.xml

<?xml version="1.0" encoding="UTF-8"?>
<persons>
    <person>
        <name>Shivani</name>
        <age>20</age>
        <gender>female</gender>
        <address>
            <doorno>75</doorno>
            <street>Shakkarnagar</street>
            <city>Bodhan</city>
            <state>Telangana</state>
            </address>
            <student>
                <rollno>14</rollno>
                <standard>17</standard>
                <section>A</section>
			</student>
	</person>
</persons>

Recommended:

Leave a Comment

Your email address will not be published. Required fields are marked *

x