The XPath Document object validates the XML document as it is loaded, but because you cannot edit the XML data in the XPath Document object, you cannot revalidate the XML document. In the case of validation, you can create an XPath Document object just like you create an Xml Document object using a validating Xml Reader object as described earlier in this topic.In order to save the contents of Validation method to file, please try using the approach shared above by Asad.Using the Xml Document class, you can validate the XML content contained in an Xml Document object in two ways. If a Validation Event Handler is set on the validating Xml Reader, the Validation Event Handler will get called whenever an invalid type is encountered. Message) Exit Sub End Select End Sub End Class After modifications are made to an XML document, you can validate the modifications against the schema for the XML document using the Validate method of the Xml Document class. XPath Class Validating Reader Example Shared Sub Main(By Val args() As String) Try Dim settings As Xml Reader Settings = New Xml Reader Settings() settings. As the XML document was loaded, any schema validation errors encountered would have been handled by the validation event handler method and written to the console. Message) Exit Sub End Select End Sub End Class In the example above, two modifications are made to the XML document contained in the Xml Document object.
For more information about read-only and editable XPath Navigator objects, see the Reading XML Data using XPath Document and Xml Document topic.I checked online if this PDF is valid and I got this error message. I have an idea on how, but I need your expert suggestion on how to do this. Apart from this approach, you may consider using following property to determine if the input file is PDF/A compliant or not.Document doc = new Document(@"C:\pdftest\input.pdf"); // determine if the input file is PDF/A compliant Console. Is Pdfa Compliant);@Musikero31 As shared above, if you need to get the content of validation method, you can save the output in Stream instance or in some separate log file on file system and then add that content to logger.The first way is to validate the XML content using a validating Xml Reader object and the second way is to use the Validate method of the Xml Document class. An Xml Schema Exception will be thrown when an attribute or element with Typed Value set to is accessed by the XPath Navigator. The following example validates the file as it is loaded into the Xml Document object by creating the Xml Document object using a validating Xml Reader object. You can also perform read-only validation of XML content using the XPath Document class. The Validity property can be used to determine whether or not an individual attribute or element is valid when accessing attributes or elements with the XPath Navigator. The XML document is validated successfully as it is loaded without generating any schema validation errors or warnings.