using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Xml;using System.Text.RegularExpressions;namespace yourprojectnamespace.subfoldername{ class DoCheckRegularExpression { public bool chkregularex(string User_defined_XPath, string User_defined_Xml_file, string User_defined_regularexpression) { bool val = false; try { XmlDocument xml_document = new XmlDocument(); xml_document.Load(User_defined_Xml_file); XmlNodeList nodelist = xml_document.SelectNodes(User_defined_XPath); foreach (XmlNode node in nodelist) { Regex pattern = new Regex(User_defined_regularexpression); string[] outcome_reg_exp = node.InnerText.Trim().Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in outcome_reg_exp) { if (pattern.IsMatch(s)) { val = true; return val; } else { val = false; } } } } catch (XmlException) { System.Windows.Forms.MessageBox.Show("Please check XML file format" ,"XML file format exception"); } return val; } }}