Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends

i have one schema
which contain element like

C#
<xs:element minOccurs="0" name="employee" nillable="true" maxOccurs="2" type="xs:string"/>


I have one xml file with no element named "employee". As per xml schema minOccurs is Zero(0), so validation should not fail.

But if there isn't any employee element, I get error in validate.

How can i solve it


please help
thanks
Posted
Updated 31-Jul-12 4:08am
v2

1 solution

hi PKriyshnA.
have you tried this:

XML
<xs:element name="employee">
   <xs:complexType>
     <xs:all minOccurs="0">
       <xs:element name="FirstN" type="xs:string"/>
       <xs:element name="LastN" type="xs:string"/>
     </xs:all>
   </xs:complexType>
 </xs:element>


The example above indicates that the "firstname" and the "lastname" elements can appear in any order and each element CAN appear zero or one time!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900