Top

Tags


Roadkill .NET Wiki

Google ads

Recommended reading


Search

Entries in xml (6)

Wednesday
Dec292010

Avoiding Unicode issues when inserting XML into a SQL Database

If you have to insert XML into a SQL Server (2005+) XML column, there's three ways of doing it...

Click to read more ...

Tuesday
Feb162010

Using XmlTextWriter to produce a XML string

This is a small snippet showing an example of using a XmlTextWriter to produce Xml that validates.

Click to read more ...

Friday
Jan012010

ConfigurationHandler snippet

This is a small snippet for the basics of writing a ConfigurationHandler to read a configuration section from your web.config or app.config.

Click to read more ...

Wednesday
Sep092009

Formatting XML in C# 

Below is a small snippet showing how to format (or re-format) XML so it's indented. XML isn't stored in this humanly readable way in databases (or in System.XML's various writers), so this method makes the XML easier on the eyes.

/// <summary>
/// Formats the provided XML so it's indented and humanly-readable.
/// </summary>
/// <param name="inputXml">The input XML to format.</param>
/// <returns></returns>
public static string FormatXml(string inputXml)
{
    XmlDocument document = new XmlDocument();
    document.Load(new StringReader(inputXml));

    StringBuilder builder = new StringBuilder();
    using (XmlTextWriter writer = new XmlTextWriter(new StringWriter(builder)))
    {
        writer.Formatting = Formatting.Indented;
        document.Save(writer);
    }

    return builder.ToString();
}
Tuesday
Aug052008

Serialization as a database in C# 

Using serialization as persistent object store (in non bs-bingo: a database)

Click to read more ...

Tuesday
Feb052008

C# XML Browser demo app

This simplistic demo app from 2004 works as a simple XML browser, showing all XML nodes in an XML document in a treeview, the value of the node and all its attributes.

It uses a recursive method on the XML rather than lazy loading.

Csharp XML browser