|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
namespace WriteXmlWithStyle
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private string ApplicationDir
{
get
{
Assembly assy = Assembly.GetExecutingAssembly();
FileInfo finfo = new FileInfo(assy.FullName);
return finfo.Directory.Parent.Parent.FullName;
}
}
private void WriteXmlBtn_Click(object sender, EventArgs e)
{
DictionarySerializer serializer = new DictionarySerializer();
Dictionary dictionary = serializer.CreateTestDictionary();
// Write the dictionary out to a file without a stylesheet reference
string xmlFile = Path.Combine(ApplicationDir, "Dictionary.xml");
File.Delete(xmlFile);
FileStream stream = File.OpenWrite(xmlFile);
try
{
serializer.Serialize(dictionary, stream, null);
}
finally
{
stream.Close();
}
// Now write the dictionary out with a stylesheet reference
xmlFile = Path.Combine(ApplicationDir, "DictionaryWithStyle.xml");
File.Delete(xmlFile);
stream = File.OpenWrite(xmlFile);
try
{
serializer.Serialize(dictionary, stream, "Dictionary.xslt");
}
finally
{
stream.Close();
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.