VerifyNMTOKEN Method

XmlConvert.VerifyNMTOKEN Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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) {
    //Display an error 
}

For more information on the NMTOKEN data type, see XML Schema Part 2: Datatypes.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft