• <bdo id='uhgq9'></bdo><ul id='uhgq9'></ul>
      <i id='uhgq9'><tr id='uhgq9'><dt id='uhgq9'><q id='uhgq9'><span id='uhgq9'><b id='uhgq9'><form id='uhgq9'><ins id='uhgq9'></ins><ul id='uhgq9'></ul><sub id='uhgq9'></sub></form><legend id='uhgq9'></legend><bdo id='uhgq9'><pre id='uhgq9'><center id='uhgq9'></center></pre></bdo></b><th id='uhgq9'></th></span></q></dt></tr></i><div id='uhgq9'><tfoot id='uhgq9'></tfoot><dl id='uhgq9'><fieldset id='uhgq9'></fieldset></dl></div>
      <tfoot id='uhgq9'></tfoot>
      <legend id='uhgq9'><style id='uhgq9'><dir id='uhgq9'><q id='uhgq9'></q></dir></style></legend>
    1. <small id='uhgq9'></small><noframes id='uhgq9'>

        模式验证 XML

        时间:2023-06-04
      1. <small id='9B9JR'></small><noframes id='9B9JR'>

        <legend id='9B9JR'><style id='9B9JR'><dir id='9B9JR'><q id='9B9JR'></q></dir></style></legend>
          <bdo id='9B9JR'></bdo><ul id='9B9JR'></ul>
            <tbody id='9B9JR'></tbody>

          <tfoot id='9B9JR'></tfoot>

              1. <i id='9B9JR'><tr id='9B9JR'><dt id='9B9JR'><q id='9B9JR'><span id='9B9JR'><b id='9B9JR'><form id='9B9JR'><ins id='9B9JR'></ins><ul id='9B9JR'></ul><sub id='9B9JR'></sub></form><legend id='9B9JR'></legend><bdo id='9B9JR'><pre id='9B9JR'><center id='9B9JR'></center></pre></bdo></b><th id='9B9JR'></th></span></q></dt></tr></i><div id='9B9JR'><tfoot id='9B9JR'></tfoot><dl id='9B9JR'><fieldset id='9B9JR'></fieldset></dl></div>

                1. 本文介绍了模式验证 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个 XSD 文件和一个 XML 文件,如何检查 XML 是否像 XSD 文件一样在正确的架构中?

                  I have an XSD file and an XML file, how can I check if the XML is in the right schema like the XSD file?

                  我知道 XmlDocument 类中有一个验证函数,但它需要一个事件处理程序我只需要对或错.

                  i know there is an validate function in the XmlDocument class, but it needs an event handler and all I need is true or false.

                  附:我在 Visual Studio 2010 中工作.

                  P.S. I'm working inVisual Studio 2010.

                  推荐答案

                  有一个很简单的方法:

                  private void ValidationCallBack(object sender, ValidationEventArgs e)
                  {  
                      throw new Exception();
                  }
                  
                  public bool validate(string sxml)
                  {
                      try
                      {
                          XmlDocument xmld=new XmlDocument ();
                          xmld.LoadXml(sxml);
                          xmld.Schemas.Add(null,@"c:	he file location");
                          xmld.validate(ValidationCallBack);
                          return true;
                      }
                      catch
                      {
                          return false;
                      }
                  }
                  

                  P.S : 我不是在 VS 中写的,所以可能有不区分大小写的单词,但这段代码有效!

                  P.S : I didn't wrote this in VS so there might be word that not in case sensitive, but this codes works!

                  这篇关于模式验证 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:通过单一方法针对 XSD 验证 XML 下一篇:从 XSD 生成 SQL Server DB

                  相关文章

                  最新文章

                2. <small id='W8aeY'></small><noframes id='W8aeY'>

                  <tfoot id='W8aeY'></tfoot>

                    <i id='W8aeY'><tr id='W8aeY'><dt id='W8aeY'><q id='W8aeY'><span id='W8aeY'><b id='W8aeY'><form id='W8aeY'><ins id='W8aeY'></ins><ul id='W8aeY'></ul><sub id='W8aeY'></sub></form><legend id='W8aeY'></legend><bdo id='W8aeY'><pre id='W8aeY'><center id='W8aeY'></center></pre></bdo></b><th id='W8aeY'></th></span></q></dt></tr></i><div id='W8aeY'><tfoot id='W8aeY'></tfoot><dl id='W8aeY'><fieldset id='W8aeY'></fieldset></dl></div>
                      <bdo id='W8aeY'></bdo><ul id='W8aeY'></ul>
                      <legend id='W8aeY'><style id='W8aeY'><dir id='W8aeY'><q id='W8aeY'></q></dir></style></legend>