編集

次の方法で共有


XmlConvert.VerifyNMTOKEN(String) Method

Definition

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

public:
 static System::String ^ VerifyNMTOKEN(System::String ^ name);
public static string VerifyNMTOKEN (string name);
static member VerifyNMTOKEN : string -> string
Public Shared Function VerifyNMTOKEN (name As String) As String

Parameters

name
String

The string you wish to verify.

Returns

The name token, if it is a valid NMTOKEN.

Exceptions

The string is not a valid name token.

name is null.

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) {
  Console.WriteLine("error");
}

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

Applies to