首页 > 解决方案 > .NET 中所有可能引发的 XmlSchemaExceptions 的列表在哪里?

问题描述

我想在 C# .NET 中使用 XmlReader 为 XmlSchemaExceptions 引发的最常见异常创建一个翻译。还没有在网上找到任何东西,也不想手动生成不同的东西..有人有这个吗?

这是我想检索它可以抛出的所有不同异常的片段:

 private void XmlValidation()
    {
        //XDocument doc = XDocument.Load(xmlFileName);
        XmlSchemaSet schemaSet = new XmlSchemaSet();
        schemaSet.Add(null, schemaFileName);
        notification.Clear();
        XmlReaderSettings xrs = new XmlReaderSettings();
        xrs.ValidationType = ValidationType.Schema;
        xrs.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
        xrs.Schemas = schemaSet;
        xrs.ValidationEventHandler += (o, s) => {
            string warn = s.Severity + ": " + s.Message;
            notification.Add(warn);
            //  Console.WriteLine("{0}: {1}", s.Severity, s.Message);
        };
        using (XmlReader xr = XmlReader.Create(xdoc.CreateReader(), xrs))
        {
            while (xr.Read()) { }
        }
    }

标签: c#.netxsd

解决方案


推荐阅读