DOM XML parser to parse XML file in java
Steps to read a XML file: 1. Create a Document with DocumentBuilder class. 2. Fetch the root element. 3. Process the child elements. 4. Process the attributes. Example: StudentTest.xml <?xml version="1.0"?> <class> <student rollno="1"> <firstname>Swati</firstname> <lastname>Aneja</lastname> <marks>80</marks> </student> <student rollno="2"> <firstname>Prabhjot</firstname> <lastname>Kaur</lastname> <marks>70</marks> </student> <student rollno="3"> <firstname>Nidhi</firstname> <lastname>Gupta</lastname> <marks>75</marks> </student> </class><?xml version="1.0"?> <class> <student rollno="1"> … Read more