Skip to main content

Checking for Required Elements and Attributes

Checking for Required Elements and Attributes

By default, the Next() method does not check for the existence of elements and attributes that correspond to properties that are marked as Required. To cause the reader to check for the existence of such elements and attributes, set the CheckRequired property of the reader to 1 before calling Next(). The default value for this property is 0, for compatibility reasons.

If you set CheckRequired to 1, and if you call Next() and the imported XML is missing a required element or attribute, the Next() method sets the sc argument to an error code. For example:

SAMPLES>set next= reader.Next(.object,.status)
 
SAMPLES>w next
0
SAMPLES>d $system.Status.DisplayError(status)
 
ERROR #6318: Property required in XML document: ReqProp
FeedbackOpens in a new tab