public static bool IsValidNCName(string ncName, out Exception err) { err = null; if (ncName.Length == 0) { err = new XmlException("NCName can not be an empty string", null); return(false); } char c = ncName[0]; if (!XmlConstructs.IsNCNameStart(c)) { err = new XmlException("The character '" + c + "' cannot start a NCName", null); return(false); } for (int i = 1; i < ncName.Length; i++) { c = ncName[i]; if (!XmlConstructs.IsNCNameChar(c)) { err = new XmlException("The character '" + c + "' is not allowed in a NCName", null); return(false); } } return(true); }
public static bool IsNCName(string str) { if (str.Length == 0) { return(false); } if (!XmlConstructs.IsFirstNameChar(str[0])) { return(false); } for (int i = 0; i < str.Length; i++) { if (!XmlConstructs.IsNCNameChar(str[i])) { return(false); } } return(true); }