Example #1
0
        public bool IsXml(string data, XmlTestDepth testDepth){
            if (Is(testDepth,XmlTestDepth.FullValidation)) return TryReadAsXml(data);

            var startsWithElement = Regex.IsMatch(data, @"^(<\?xml[\s\S]+?\?>)?\s*<\w+[\s\S]+?/?>",
                                                  RegexOptions.Compiled);
            var endsWithElement = Regex.IsMatch(data, @"<\w+[\s\S]*?/?>\s*$", RegexOptions.Compiled);
            return startsWithElement && endsWithElement;
        }
Example #2
0
 public static string WrapAsTextIfNeeded(string data, XmlTestDepth depth){
     if (!XmlTestBase.GetIsXml(data, depth)) return WrapAsText(data);
     return data;
 }
Example #3
0
 public static bool GetIsXml(string data, XmlTestDepth depth){
     return new XmlTestBase().IsXml(data, depth);
 }
Example #4
0
 public IXmlTest GetXmlTest(string data, XmlTestDepth testDepth, params object[] advancedParameters){
     return this;
 }