Extensions::GetSchemaInfo Method (XElement^)
Gets the post-schema-validation infoset (PSVI) of a validated element.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
Parameters
- source
-
Type:
System.Xml.Linq::XElement^
An XElement that has been previously validated.
Return Value
Type: System.Xml.Schema::IXmlSchemaInfo^A IXmlSchemaInfo that contains the post-schema-validation infoset (PSVI) for an XElement.
You can use the IXmlSchemaInfo returned by this method to determine certain characteristics of a validated element. For example, you can determine the dynamic schema type of the element.
You use the SchemaElement property to get a partial validation type (XmlSchemaElement). You can use it to revalidate a sub-tree with an element at its root without validating an entire document.
For an example of this property, see Validate.
The following example populates the tree with a PSVI. After validation, it prints all elements and attributes in the tree that are invalid according to the PSVI.
This example produces the following output:
Validating doc1 ... The 'GrandChild2' element is invalid - The value 'ZZZ' is invalid according to its datatype 'GCType' - The Enumeration constraint failed. The 'GrandChild3' element is invalid - The value 'ZZZ' is invalid according to its datatype 'GCType' - The Enumeration constraint failed. doc1 did not validate Invalid Element /Root Invalid Element /Root/Child1 Invalid Element /Root/Child1/GrandChild2 Invalid Element /Root/Child1/GrandChild3
Available since 3.5