Verify Xml Chars : XML Convert « XML LINQ « C# / C Sharp






Verify Xml Chars

 


using System;
using System.Xml;

public class Sample
{

    public static void Main()
    {

        XmlTextWriter writer3 = new XmlTextWriter("outFile.xml", null);
        char illegalChar = '\uFFFE';
        string charsToVerify = "Test String ";
        try
        {
            writer3.WriteStartElement("root");
            writer3.WriteStartElement(XmlConvert.VerifyXmlChars(charsToVerify + illegalChar));
            writer3.WriteString("ValueText");
            writer3.WriteEndElement();
            writer3.WriteEndElement();
            writer3.Close();
        }
        catch (XmlException e)
        {
            Console.WriteLine(e.Message);
            writer3.Close();
        }
    }
}

   
  








Related examples in the same category

1.Decodes a name. This method does the reverse of the EncodeName and EncodeLocalName methods.
2.Converts the supplied String to a DateTimeOffset equivalent.
3.Converts the DateTime to a String.
4.Converts the supplied DateTimeOffset to a String.
5.Converts the supplied DateTimeOffset to a String in the specified format.
6.Verifies that the name is a valid name according to the W3C Extended Markup Language recommendation.