Validate XML against a schema

  private static string ValidateXML(string xsd, string strXml,string emailfrom,string emailto)

    {

      string ret = "";

      string xsdfolder = ConfigurationManager.AppSettings["xsdfolder"];

         xsd = "cr_caseinfo.xsd";

      string schemaPath = xsdfolder + xsd;

      try

      {

        XmlDocument xml = new XmlDocument();

        xml.LoadXml(strXml);

        xml.Schemas.Add(null, schemaPath);

        xml.Validate(null);

      }

      catch (Exception ex)

      {

        Email.SendMail(emailfrom, emailto, "XML validation Error", ex.Source + "-" + ex.Message);

        // throw new WebFaultException(HttpStatusCode.BadRequest);

        ret = ex.Message;

      }

      return ret;

    }

要查看或添加评论,请登录

Daniel Liu的更多文章

  • database table partition

    database table partition

    Some database tables grow and become a super large tables. Usually we either archive or partition the large tables.

  • unable to access to SQL server database diagram

    unable to access to SQL server database diagram

    I login as sa to a SQL server, trying to create a new database diagram, but unable to access it. Got following error…

  • SQL group by sample query

    SQL group by sample query

    query 1: --use group by rollup() select isNull(CONVERT(VARCHAR(4), FILED_RECEIVED_DATE, 126), case when…

  • C# get first friday in any month, any year

    C# get first friday in any month, any year

    public string GetFirstFriday(int year,int month) { string friday=null; for (int i = 1; i 8; i++) { var dtmDate = new…

  • Blob data and PDF conversion in C#

    Blob data and PDF conversion in C#

    save Blob data from oracle to PDF file: private static void SaveBlobToPDF(string constr, string filing_id) { using…

  • Replace Apostrophe in SQL linked server query

    Replace Apostrophe in SQL linked server query

    I need to search employee's last name from SQL server to DB2 database, one lastname like O'NEIL cause the error, here…

  • send email from c#

    send email from c#

    using System.Net.

  • read email from active directory

    read email from active directory

    private static string GetEmailAddressLDAP(string strEnv, string empno) { string strLDAPConnection; string strLDAPId;…

  • Multi-tenant Database design

    Multi-tenant Database design

    There are 4 options to design Multi-tenant database: 1. One big database, one schema(dbo): In this approach, database…

  • Create Excel from List<T>

    Create Excel from List<T>

    I need to generate the excel file by querying database everyday. All the data returned as List.

社区洞察

其他会员也浏览了