how to validate mandatory fields in XML
Posted: Wed Nov 10, 2010 7:37 am
Hi,
I am working with the XML files and I have imported the XSD document. XSD has information of all the mandatory and non mandatory fields.
I want to have a check and trace while parsing XML in case XML document does not have mandatory field.
In example below
<body>
<text>
<id>123</id>
<name>ABCD</name>
</text>
<text>
<id>12345</id>
<name>ABC</name>
</text>
</body>
In normal case I get 2 records as:
123 ABCD
12345 ABC
But if I remove mandatory field 'id' in one of the segment then I get only 1 record.
Example XML:
<body>
<text>
<name>ABCD</name>
</text>
<text>
<id>12345</id>
<name>ABC</name>
</text>
</body>
Output:
12345 ABC
Could any one help me to trace the rejected record and how can I check the presence of mandatory field 'id' in XML document.
Thanks.
I am working with the XML files and I have imported the XSD document. XSD has information of all the mandatory and non mandatory fields.
I want to have a check and trace while parsing XML in case XML document does not have mandatory field.
In example below
<body>
<text>
<id>123</id>
<name>ABCD</name>
</text>
<text>
<id>12345</id>
<name>ABC</name>
</text>
</body>
In normal case I get 2 records as:
123 ABCD
12345 ABC
But if I remove mandatory field 'id' in one of the segment then I get only 1 record.
Example XML:
<body>
<text>
<name>ABCD</name>
</text>
<text>
<id>12345</id>
<name>ABC</name>
</text>
</body>
Output:
12345 ABC
Could any one help me to trace the rejected record and how can I check the presence of mandatory field 'id' in XML document.
Thanks.