Use Linq to XML with Flare Files (part 1)

Linq to XML is a library for XML manipulation for use with Microsoft’s Visual Basic and Visual C#. Linq to XML offers extensive functionality at the cost of limiting development to a .NET context. Microsoft posts information about Linq to XML here:

The Visual Basic manifestation of the System.XML.Linq interface is particularly interesting because it allows you to work with XML markup in-line with the Visual Basic code as an XML literal. For example, to create a new Flare topic from an application which uses Linq to XML, the code could look like this:

Imports System.Xml.Linq
Module Module1
    Sub Main()
        Dim FlareTopicDoc As XDocument = _
            <?xml version="1.0" encoding="utf-8"?>
            <html xmlns:MadCap="">
                    <h1>New Flare Topic</h1>
                    <p>This was created with a command line application.</p>

    End Sub
End Module

That document could also have been created with Linq to XML with C#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace LinqToXMLExampleCSharp
    class Program
        static void Main(string[] args)
            XNamespace n = "";
            XDocument FlareTopicDoc = new XDocument(
                new XDeclaration("1.0", "utf-8", "yes"),
                new XElement(n + "html",
                    new XElement(n + "head"),
                    new XElement(n + "body",
                        new XElement(n + "h1", "New Flare Topic"),
                        new XElement(n + "p", "This was created with a command line application.")


Leave a comment

Your email address will not be published.

HTML tags are not allowed.

251,556 Spambots Blocked by Simple Comments