This program checks whether an XML file has properly nested tags.
It reads the XML content from a file named note.xml and verifies that every opening tag has a matching closing tag in the correct order.
The program uses a stack data structure to keep track of opening tags.
- When an opening tag (e.g., ) is found, it is pushed onto the stack.
- When a closing tag (e.g., ) is found, the program pops the top element from the stack.
- The popped tag is compared with the closing tag:
- If they match, the structure is correct.
- If they do not match, the XML is invalid.
- After processing the entire file:
- If the stack is empty, the XML is valid.
- Otherwise, the XML is invalid.
- xml_validator.c : Main C program
- note.xml : Sample XML input file
gcc xml_validator.c -o main.exe ./main.exe
XML is valid
Student Assignment — Data Structures / Programming Course