System.Xml.XmlConvert.VerifyName Method

Verifies that the name is a valid name according to the W3C Extended Markup Language recommendation.

Syntax

public static string VerifyName (string name)

Parameters

name
The name to verify.

Returns

The name, if it is a valid XML name.

Exceptions

TypeReason
ArgumentNullException name is null or string.Empty.
System.Xml.XmlException name is not a valid XML name.

Remarks

This method can be used with the System.Xml.XmlWriter class in the following manner.

Example

 try{
   writer.WriteStartElement(XmlConvert.VerifyName("item"),"bar");
 }
 catch(Exception e)
 {
   Console.WriteLine("error");
 }

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0