[Mono-list] Using WriteAttributeString so that it works in 2.4 and 2.6

Andrus kobruleht2 at hot.ee
Mon Mar 15 12:28:13 EDT 2010


Line

writer.WriteAttributeString("xmlns", "o", "", 
"urn:schemas-microsoft-com:office:office");

in code below causes exception in 2.6

writer.WriteAttributeString("xmlns", "o", null, 
"urn:schemas-microsoft-com:office:office");

causes exception in 2.4.

How to make code below work in 2.4 and in 2.6 ?

Andrus.


using System;
using System.IO;
using System.Xml;

class Program
{
    static void Main()
    {
        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Indent = true;
        settings.IndentChars = "    ";
        XmlWriter writer = XmlWriter.Create(new MemoryStream(), settings);
        writer.WriteStartDocument();
        writer.WriteProcessingInstruction("mso-application", 
"progid=\"Excel.Sheet\"");
        writer.WriteWhitespace("\n");
        writer.WriteStartElement("Workbook", 
"urn:schemas-microsoft-com:office:spreadsheet");
        writer.WriteAttributeString("xmlns", "o", "", 
"urn:schemas-microsoft-com:office:office");
        Console.ReadLine();
    }
} 



More information about the Mono-list mailing list