0% found this document useful (0 votes)
46 views

Assignment 1 1-1

This assignment requires students to: 1. Write a C++ program to validate an HTML document by checking if tags are valid and properly nested 2. The program should read a list of valid HTML tags from a file and store them in a vector 3. For valid HTML tags and nesting, the output should be "Valid HTML document"; otherwise, an error message.

Uploaded by

Malik Ghulam Hur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Assignment 1 1-1

This assignment requires students to: 1. Write a C++ program to validate an HTML document by checking if tags are valid and properly nested 2. The program should read a list of valid HTML tags from a file and store them in a vector 3. For valid HTML tags and nesting, the output should be "Valid HTML document"; otherwise, an error message.

Uploaded by

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

Assignment 1

General Rules

 It is an individual assignment, it needs to be done individually and you are


not to exchange or share materials with other students.
 Use C++ for coding.
 Submit your assignment on MS Team as a zip file. The name of the file
should be your name with your roll number and section (name-
rollnumber-section.zip)
 Late submissions are not accepted.

This assignment is due by 6:00 p.m. on Monday, 16 November.


Background

An HTML (Hyper Text Mark-up Language) document is a sequence of zero or


more of tags interspersed with arbitrary other text. There are two types of tags:
open tags and close tags. The format of an open tag is
<htmltagname>

Where htmltagname is a sequence of one or more alpha-numeric characters. The


format of a close tag is
</htmltagname>

where tagname is defined as for open tags.

An open tag and a close tag match if all of the following are true:

1. The name of the open tag matches the name of the close tag. For example,
the names in the open and close tags <h1> and </ H1 > match, but the
names in the open and close tags <div> and </p> don't match.
2. The open tag precedes the close tag in the document. For example, the
open tag precedes the close tag in
3. ... <p> ... </p> ...

but does not precede the close tag in


... </p> ... <p> ...
4. All the tags between the open and close tags also match (this is the nesting
condition). For example, the b tags match in
... <p> <b> </b> </p> ...

The Problem

Write a C++ program that reads an HTML document and validate HTML. During
validation it checks whether HTML tag is valid or not and HTML tags are
properly nested in the document. You can read a list of valid HTML tags from a
file and store in a vector. In case of valid HTML tags and properly nested tags
your program should output “Valid HTML document”; otherwise, it should
output an informative error and stop.

You might also like