In C#, how to determine the XSD-defined MaxLength for an element

后端 未结 2 1478
轮回少年
轮回少年 2020-12-16 07:39

I\'m using XmlReader with an attached XSD for validation.

As my XML document is being read and validated, I want to determine in my C# code the \'maxLength\' value s

相关标签:
2条回答
  • 2020-12-16 08:25

    you'll find here:Accessing XML Schema Information During Document Validation a good explanation of how to do this & more.

    0 讨论(0)
  • 2020-12-16 08:30

    There are ways to do so with myReader.SchemaInfo (see najmeddine's response), but in case you need to access stuff not exposed in the SchemaInfo object...

    ..XSD being an XML Language. You can simply load the XSD file and using XPath find the "testing" element's definition, and its maxLength.

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