XmlConvert.VerifyNMTOKEN Method (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public static string VerifyNMTOKEN(
	string name
)

Parameters

name
Type: System.String

The string you wish to verify.

Return Value

Type: System.String

The name token, if it is a valid NMTOKEN.

Exception Condition
XmlException

The string is not a valid name token.

ArgumentNullException

name is null.

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

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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: