Validating XML documents with XSD correctly

前端 未结 1 1765
轻奢々
轻奢々 2021-01-13 04:24

As a developer with a good deal of XML consuming and producing experience, I\'ve never really interacted with schemas before. For the first time this is actually occurring

相关标签:
1条回答
  • 2021-01-13 05:09

    There is no nodes in your XML that can be validated by the schema (namespaces are different). As result it does not report any errors. As far as I know behavior for nodes that are not matched to any schema is allow anything.

    You also could set validation options in XmlReaderSettings to allow warnings:

    ReportValidationWarnings - Indicates that events should be reported if a validation warning occurs. A warning is typically issued when there is no DTD or XML Schema to validate a particular element or attribute against. The ValidationEventHandler is used for notification.

    Check out XmlSchemaSet.Add and HOW TO: Validate an XML Document by Using Multiple Schemas if you expect nodes from multiple namespaces to be present in the XML.

    0 讨论(0)
提交回复
热议问题