I have a XML file in which I have certain attributes. And I have implementation classes to parse the file to get the values. But When I tested with missing values it works fine. My program wants to throw error or warning when it runs. Please suggest me a solution.
sample "hello.xml"
<head>
<welcome>Hi</welcome>
<id>1</id>
<uname>chill</uname>
<persons>
<person>
<name>1</name>
<age>23</age>
<city>huils</city>
</person>
<person>
<name>2</name>
<age>23</age>
<city>huils</city>
</person>
<person>
<name>3</name>
</person>
</persons>
</head>
Now in person 3 I have missing attributes and tags age and city. But my program works fine without throwing error. Whats wrong.
Implementation program :
@XmlElementWrapper(name="welcome")
public void setwelcome(String welcome) {
welcome= welcome;
}
@XmlElement (name = "id")
public void setid(String id) {
id= id;
}
@XmlElement (name = "id")
public void setid(String id) {
id= id;
}
@XmlElement (name = "name")
public void setname(String name) {
name= name;
}
@XmlElement(name="age")
public void setage(String age) {
age= age;
}
@XmlElement(name="city")
public void setage(String city) {
city= city;
}