System.Xml.XmlConvert.VerifyNMTOKEN Method

Verifies that the string is a valid NMTOKEN according to the W3C XML Schema Part2: Datatypes recommendation

Syntax

public static string VerifyNMTOKEN (string name)

Parameters

name
The string you wish to verify.

Returns

The name token, if it is a valid NMTOKEN.

Remarks

This method ensures that the name token follows the proper syntax for a valid NMTOKEN. It can be used in the following manner:

Example

try {
  writer.WriteStartElement(XmlConvert.VerifyNMTOKEN("abc"),"book");
}
catch(Exception e) {
  Console.WriteLine("error");
}

For more information on the NMTOKEN data type, see http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#NMTOKEN.

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0