Question: You are asked to write a program to check if the HTML tags in a given file are nested correctly or not. This problem is

You are asked to write a program to check if the HTML tags in a given file are nested correctly or not. This problem is similar to the example of proper matching of { ( [ ] ) }, but now you will deal with HTML tags and read them from a file. You need to implement and use use stack lib that we discussed in class with typedef void *stackElementT; or typedef char *stackElementT;

For example, if an HTML file contains

THIS FILE USES CORRECTLY NESTED TAGS

First header text You are asked to write a program to check if the HTML

Some other text

Then YES, all the tags are nested correctly.

But if an HTML file contains

THIS FILE IS NOT NESTED CORRECTLY .

some text is not nested correctly

Then NO, the tag violates the proper nesting!

Your program must accept HTML input file name as a command line argument and process it for proper nesting of HTML tags. You can stop the program when you detect the first tag that violates the proper nesting structure and print NO and the tag that violates nesting on the screen. Otherwise, your program will print YES, all the tags are nested correctly.

Step by Step Solution

3.44 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem you need to implement a stackbased approach to verify if the HTML tags in a fi... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

609507d608088_25477.pdf

180 KBs PDF File

Word file Icon

609507d608088_25477.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!