惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
T
Tailwind CSS Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
N
News and Events Feed by Topic
月光博客
月光博客
TaoSecurity Blog
TaoSecurity Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
N
News | PayPal Newsroom
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Privacy & Cybersecurity Law Blog
GbyAI
GbyAI
K
Kaspersky official blog
WordPress大学
WordPress大学
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 叶小钗
W
WeLiveSecurity
Jina AI
Jina AI
The Cloudflare Blog
Project Zero
Project Zero
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
L
LangChain Blog
Forbes - Security
Forbes - Security
PCI Perspectives
PCI Perspectives
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
博客园 - 【当耐特】
H
Heimdal Security Blog
A
About on SuperTechFans
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
云风的 BLOG
云风的 BLOG
Spread Privacy
Spread Privacy
L
LINUX DO - 最新话题
L
Lohrmann on Cybersecurity
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
Intezer
Martin Fowler
Martin Fowler
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint

博客园 - Danny Chen

python asyncio 获取协程返回值和使用callback c#等待所有子线程执行完毕方法 Python virtualenv 查看当前正在运行的python进程 Mac 删除/卸载 自己安装的python python读取txt文件最后一行(文件大+文件小) pycharm 注册码/License server 2017年最新 Linux cat命令详解 在Mac平台上安装配置ELK时的一些总结 Mac上搭建ELK C#中XML与对象之间的序列化、反序列化 C#位运算 SQL Server 权限管理 如何用C#动态编译、执行代码 [C#]手把手教你打造Socket的TCP通讯连接(一) C#动态调用WCF接口,两种方式任你选。 动态调用WCF服务 矩阵的坐标变换(转) 【.NET线程--进阶(一)】--线程方法详解
C#中用schema验证xml的合法性
Danny Chen · 2017-09-19 · via 博客园 - Danny Chen
class ValidateXML
    {
        public string ErrString = string.Empty;
        public void ValidationEventCallBack(Object sender, ValidationEventArgs e)
        {
            if (e.Severity == XmlSeverityType.Warning)//区分是警告还是错误 
            {
                //Console.WriteLine("验证成功!警告:" + e.Message);
                ErrString += "验证成功!警告:" + e.Message;
            }
            else
            {
               // Console.WriteLine("验证失败");
                ErrString += "Err:" + e.Message;
            }
        }

        public void CheckXmlValidate(string strRequestXML)
        {
            //string ErrString = string.Empty;
            StringReader sRead = null;
            XmlReader xmlRead = null;
            XmlSchemaSet schemaSet;

            try
            {
                schemaSet = new XmlSchemaSet();

                sRead = new StringReader(strRequestXML);

                schemaSet.Add(null, @"MySchema.xsd");

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventCallBack);
                settings.ValidationType = ValidationType.Schema;
                settings.Schemas = schemaSet;

                xmlRead = XmlReader.Create(sRead, settings);
                while (xmlRead.Read())
                {

                }

                if (ErrString.ToString() == String.Empty)
                {

                    Console.WriteLine("验证成功!");
                }
                else
                {
                    Console.WriteLine("验证失败!原因可能是:" + ErrString);
                }
            }
            catch (XmlException exec)
            {
                Console.WriteLine(exec.Message);
            }
            finally
            {

                if (xmlRead != null)
                {

                    xmlRead.Close();
                }
            }
        }
    }

public static void Main(string[] args)
        {
ValidateXML vx = new ValidateXML();
            //StreamReader sr = new StreamReader(new FileStream(@"test.xml", FileMode.Open));
            vx.CheckXmlValidate(File.ReadAllText(@"test.xml"));

            PressQtoQuit();
        }

public static void PressQtoQuit()
        {
            Console.WriteLine("Hit Q to exit");
            ConsoleKey key;
            do
            {
                key = Console.ReadKey().Key;
            } while (key != ConsoleKey.Q);
        }

Reference from : https://msdn.microsoft.com/en-us/library/as3tta56(v=vs.80).aspx

Reference from : http://www.cnblogs.com/joean/p/4982875.html