XmlConvert.VerifyNMTOKEN Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
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)
Syntax
'Declaration
Public Shared Function VerifyNMTOKEN ( _
name As String _
) As String
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.
Exceptions
Exception | Condition |
---|---|
XmlException | The string is not a valid name token. |
ArgumentNullException | name is nulla null reference (Nothing in Visual Basic). |
Remarks
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.
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.