MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

JAVA XML

JavaXml Projects

JavaXml Project 1

JavaXml Examples

JavaXml EXAMPLE

XML checker Error and locater
Previous Home Next

In this program, we will be learn to check the error and locate them by line and by column number in our XML document using the DOM Application programming interface. The XML document follows some rules to check its.

Here is the XML File: Student_Detail1.xml

<?xml version = "1.0" ?>
<Student_Detail1>
<Student>
<stu_Id> s-001 </stu_Id>
<stu_Name> ajay </stu_Name>
<stu_E-mail> ajay1@yahoo.com </stu_E-mail>
</Student>
</Student_Detail1>

Here is the Java File: Finderror.java

 

package r4r;
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public class finderror {
	public static void main(String[] arg){
		try {
		BufferedReader br = new BufferedReader(new
		InputStreamReader(System.in));
		System.out.print("Enter the File name: ");
		String str = br.readLine();
		File file = new File(str);
		if(file.exists()){
		DocumentBuilderFactory fact = 
		DocumentBuilderFactory.newInstance();
		DocumentBuilder build = fact.newDocumentBuilder();
		Document docu = build.parse(str);
		System.out.println(str + " well");
		}
		else{
		System.out.print("File not found!");
		}
		}[an error occurred while processing this directive]
		catch (SAXParseException e) {
		System.out.println("type" + ": " + e.getMessage()+"\n");
		System.out.println("Line " + e.getLineNumber() + " Column "
		+ e.getColumnNumber());
		}
		catch (SAXException e) {
		System.err.println(e);
		System.exit(1);
		}
		catch (ParserConfigurationException e) {
		System.err.println(e);
		System.exit(1);
		}
		catch (IOException e) {
		System.err.println(e);
		System.exit(1);
		}
		}
}

Previous Home Next