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

后端 未结 2 1481
轮回少年
轮回少年 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: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.

提交回复
热议问题