In this section, you will learn to check the well-formed-ness of a XML using the DOM interface. A well-formed XML document must follow the xml syntax rules.
Description of program:
For checking the "well-formedness" of a XML document you should use the given example. The DOM parser parsers (parse()) the XML document using the DocumentBuilder and DocumentBuilderFactory. Whenever the XML document is well-formed, it shows a message "Employee-Detail.xml is well-formed". Otherwise it displays "Employee-Detail.xml isn't well-formed.".
Here is the XML File: Employee-Detail.xml
|<?xml version = "1.0" ?>
<Emp_Id> E-001 </Emp_Id>
<Emp_Name> Vinod </Emp_Name>
<Emp_E-mail> Vinod1@yahoo.com </Emp_E-mail>
<Emp_Id> E-002 </Emp_Id>
<Emp_Name> Amit </Emp_Name>
<Emp_E-mail> Amit2@yahoo.com </Emp_E-mail>
<Emp_Id> E-003 </Emp_Id>
<Emp_Name> Deepak </Emp_Name>
<Emp_E-mail> Deepak3@yahoo.com </Emp_E-mail>
Here is the Java File: DOMParserCheck.java
Output of program:
Enter File name: Employee-Detail.xml
Employee-Detail.xml is well-formed!
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.