public static bool IsValidName(string name, out Exception err)
        {
            err = null;
            if (name.Length == 0)
            {
                err = new XmlException("Name can not be an empty string", null);
                return(false);
            }
            char c = name[0];

            if (!XmlConstructs.IsFirstNameChar(c))
            {
                err = new XmlException("The character '" + c + "' cannot start a Name", null);
                return(false);
            }
            for (int i = 1; i < name.Length; i++)
            {
                c = name[i];
                if (!XmlConstructs.IsNameChar(c))
                {
                    err = new XmlException("The character '" + c + "' is not allowed in a Name", 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);
 }
 public static int IsValidName(string name)
 {
     if (name.Length == 0)
     {
         return(0);
     }
     if (!XmlConstructs.IsFirstNameChar(name[0]))
     {
         return(0);
     }
     for (int i = 1; i < name.Length; i++)
     {
         if (!XmlConstructs.IsNameChar(name[i]))
         {
             return(i);
         }
     }
     return(-1);
 }