{"id":29,"date":"2012-08-10T01:45:39","date_gmt":"2012-08-10T01:45:39","guid":{"rendered":"http:\/\/tregner.com\/flare-blog\/?p=29"},"modified":"2012-08-10T13:09:49","modified_gmt":"2012-08-10T13:09:49","slug":"use-linq-to-xml-with-flare-files-part","status":"publish","type":"post","link":"https:\/\/tregner.com\/flare-blog\/use-linq-to-xml-with-flare-files-part\/","title":{"rendered":"Use Linq to XML with Flare Files (part 1)"},"content":{"rendered":"<p>Linq to XML is a library for XML manipulation for use with Microsoft&#8217;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: <![CDATA[ ]]><\/p>\n<p><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb387098\" target=\"_blank\">http:\/\/msdn.microsoft.com\/en-us\/library\/bb387098<\/a><\/p>\n<p>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\u00a0literal. For example, to create a new Flare topic from an application which uses Linq to XML, the code could look like this:<\/p>\n<div class=\"CodeIndent\">\n<pre xml:space=\"preserve\">Imports System.Xml.Linq\r\nModule Module1\r\n    Sub Main()\r\n        Dim FlareTopicDoc As XDocument = _\r\n            &lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n            &lt;html xmlns:MadCap=\"http:\/\/www.madcapsoftware.com\/Schemas\/MadCap.xsd\"&gt;\r\n                &lt;head&gt;\r\n                &lt;\/head&gt;\r\n                &lt;body&gt;\r\n                    &lt;h1&gt;New Flare Topic&lt;\/h1&gt;\r\n                    &lt;p&gt;This was created with a command line application.&lt;\/p&gt;\r\n                &lt;\/body&gt;\r\n            &lt;\/html&gt;\r\n\r\n        FlareTopicDoc.Save(\"C:\\FlareExamples\\FlareTopicDoc.htm\")\r\n    End Sub\r\nEnd Module<\/pre>\n<\/div>\n<p>That document could also have been created with Linq to XML with C#:<\/p>\n<div class=\"CodeIndent\">\n<pre xml:space=\"preserve\">using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Xml.Linq;\r\n\r\nnamespace LinqToXMLExampleCSharp\r\n{\r\n    class Program\r\n    {\r\n        static void Main(string[] args)\r\n        {\r\n            XNamespace n = \"http:\/\/www.madcapsoftware.com\/Schemas\/MadCap.xsd\";\r\n            XDocument FlareTopicDoc = new XDocument(\r\n                new XDeclaration(\"1.0\", \"utf-8\", \"yes\"),\r\n                new XElement(n + \"html\",\r\n                    new XElement(n + \"head\"),\r\n                    new XElement(n + \"body\",\r\n                        new XElement(n + \"h1\", \"New Flare Topic\"),\r\n                        new XElement(n + \"p\", \"This was created with a command line application.\")\r\n                        )\r\n                    )\r\n                );\r\n\r\n            FlareTopicDoc.Save(\"C:\\\\FlareExamples\\\\FlareTopicDoc.htm\");\r\n        }\r\n    }\r\n}<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Linq to XML is a library for XML manipulation for use with Microsoft&#8217;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: http:\/\/msdn.microsoft.com\/en-us\/library\/bb387098 The Visual Basic manifestation of the System.XML.Linq interface is particularly interesting because&hellip; <a class=\"more-link\" href=\"https:\/\/tregner.com\/flare-blog\/use-linq-to-xml-with-flare-files-part\/\">Continue reading <span class=\"screen-reader-text\">Use Linq to XML with Flare Files (part 1)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[6,5],"_links":{"self":[{"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/posts\/29"}],"collection":[{"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/comments?post=29"}],"version-history":[{"count":10,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":64,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/posts\/29\/revisions\/64"}],"wp:attachment":[{"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/media?parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/categories?post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/tags?post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}