Exception: cvc-datatype-valid.1.2.2: ' ' is not a valid value for integer

Arunim sharma picture Arunim sharma · Jul 3, 2017 · Viewed 11.3k times · Source
<?xml version="1.0"?>
<departments>
<department>
    <deptid>1</deptid>
    <dname>Sales</dname>
    <employee>
        <empid>1001</empid>
        <name>Tom</name>
        <salary>20000</salary>
        <email>[email protected]</email>
        <phoneno>9874563210</phoneno>
    </employee>
</department>
<department> <!--deptid and dname for some coloums are empty-->
   <deptid></deptid>
   <dname></dname>
    <employee>
        <empid>1002</empid>
        <name>Sam</name>
        <salary>25000</salary>
        <email>[email protected]</email>
        <phoneno></phoneno>
    </employee>
</department>
<department>
   <deptid></deptid>
   <dname></dname>
    <employee>
        <empid>1003</empid>
        <name>Shiny</name>
        <salary>20000</salary>
        <email></email>
        <phoneno>9876543210</phoneno>
    </employee>
</department>
<department>
    <deptid>2</deptid>
    <dname>Admin</dname>
    <employee>
        <empid>1006</empid>
        <name>Ram</name>
        <salary>15000</salary>
        <email>[email protected]</email>
        <phoneno>9873214560</phoneno>
    </employee>
</department>
<department>
   <deptid></deptid>
   <dname></dname>
    <employee>
        <empid>1007</empid>
        <name>Gupta</name>
        <salary>17000</salary>
        <email></email>
        <phoneno>9632587410</phoneno>
    </employee>
</department>

Exception: cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'.

Contains employee details of five employees. I tried to document a well formed xml but I am getting error each time i execute it, Please help me with it.

employee details

I have mentioned the root element as departments and subsequently other elements.

Answer

amit biswas picture amit biswas · Jul 21, 2017

try putting some values over there instead of leaving them empty, i.e:

<phoneno>0</phoneno>
<email>nil</email>

it'll work.