Export (0) Print
Expand All

XmlConvert.VerifyNMTOKEN Method

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.

ExceptionCondition
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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft