|
|
Browse by Tags
All Tags » LINQ » LINQ to XML (RSS)
-
Visual Basic 9.0 added many language features that allow us to write in the functional style in a natural and expressive way. The value of programming in the functional style has been apparent to me for some time, and VB developers can realize the same benefits as C# developers, so I’ve written a tutorial for VB developers: Query Composition using Functional Programming Techniques in VB 9.0 . This tutorial is a rewrite of a tutorial that I wrote in the early part of 2008, Query Composition using Read More...
|
-
I recently posted some code that allows you to use LINQ to query Excel tables . The source for these queries is the Open XML document – you don’t need to involve the Excel application to query the data in these tables. In that post, I presented a few examples of queries of various types. This post shows a join of two tables using the extension methods and classes presented in that post. The source for this query is a spreadsheet where I imported two columns of the Northwind data into two worksheets. Read More...
|
-
[Blog Map] Excel has a very cool feature where you can declare that a range of cells is a table. It is a feature that allows you to use Excel very much like a database. You can add new rows as necessary, sort the table by columns, do some simple filtering, calculate the sum of columns, and more. Each table has a unique table name, and each column has a name unique to its table. Because these tables are stored in Open XML documents, we can implement some simple extension methods and some classes so Read More...
|
-
[Blog Map] Debugging LINQ queries can be problematic. One of the reasons is that quite often, you write a large query as a single expression, and you can’t set a breakpoint mid-expression. Writing large queries in expression context is particularly powerful when using functional construction to form XML (or using the strongly typed DOM in Open XML SDK V2). This post presents a little trick that makes it easier to use the debugger with LINQ queries that are written using ‘method syntax’. The gist Read More...
|
-
I’ll be presenting two sessions on the Open XML SDK at Tech Ed 2008 EMEA in Barcelona. OFC206 - Open XML SDK Version 2 Overview and Architecture (November 12, 13:30 - 14:45) In this session, I’ll present an overview of V2 of the Open XML SDK. I’ll talk a bit about the architecture of the Open XML formats. I’ll then compare and contrast the Office object model and the Open XML SDK, and the key benefits from using the SDK. We’ll discuss the architecture of the Open XML SDK, and the roadmap for the Read More...
|
-
[Blog Map] Anders Hejlsberg presented a fascinating and entertaining session at PDC 2008 on C# 4.0 . He talked about dynamic typing, optional and named parameters, improved COM interoperability, and improved support for co-variance and contra-variance. These language improvements are very cool – they enable us to write code that more closely expresses our intent, with less syntactic noise. Carve out some time, and watch his PDC session . Anders is a dynamic presenter, so you won’t be bored! Dynamic Read More...
|
-
You can build very powerful document assembly solutions using the Open XML SDK V2 literally in just a few minutes. In our presentation at PDC 2008, amongst other demos, Zeyad Rajabi and I will demonstrate this in a live coding session. We'll be using the LINQ friendly features of the SDK. It really is a quite a remarkable set of tools, and if you are an Open XML aficionado, you really should attend our session! But even more important than that, we really want to see you, and hear your questions Read More...
|
-
You may optionally be making a number of modifications to a very large XDocument object. Because of a complicated algorithm, you may not necessarily know ahead of time whether you will be making changes. If you don’t make any changes, then you don’t want to unnecessarily serialize the tree and save it to disk, or send it over the wire. This post presents a simple technique to determine if an XDocument has ever been modified since deserialization or creation. For example, you might have a very large Read More...
|
-
LINQ is a great tool for writing ad-hoc queries and transforms, and occasionally I need to write queries or transforms on text files. And sometimes I receive CSV files, and need to do something with them. I wrote a blog post on LINQ to Text files over two years ago. My coding practices today differ from what I presented in that blog post. This post presents my current approach for dealing with text files using LINQ, and includes a function for splitting CSV lines. In that post, I detailed an approach Read More...
|
-
Many types of documents contain code, including API documentation, tutorials, specifications, technical books, and magazine articles. Too often, there is no way to automate testing and validation of this code. This post presents a small example program that shows how to use content controls in Open XML word documents to delineate code snippets so that you can automate validation of the snippets. This scenario was my first use of Open XML – it was the killer application (for me) that prompted me to Read More...
|
-
Today, the development team for the Open XML SDK has announced that they have released the first Community Technology Preview (CTP) of version 2 of the Open XML SDK. Download it at http://go.microsoft.com/fwlink/?LinkId=127912 . There is a lot of very cool stuff in this release, including: Strongly typed document object model (DOM). Tool to compare two Open XML files. Class explorer that helps you understand the markup and determine which classes to use in the strongly typed DOM. Document reflector Read More...
|
-
Content controls are an effective way to add structure to word processing documents. You can write a very small LINQ query to retrieve the contents of content controls. This topic in Office Online provides more information on content controls. In an upcoming post, I’m going to show how you can write a small test harness to test code that is embedded in documents. This is particularly useful, say, to a program manager who has written a specification that contains a lot of code that shows how to use Read More...
|
-
You can use lambda expressions to write an event handler, even for classes that predate C# 3.0 and the latest version of the framework. This can shorten your code, and make it easier to read. For example, the code to validate an XML tree using an XSD schema takes an event handler because it may return multiple errors or warnings for a single validation pass. An easy way to write this code is as follows: using System; using System.Linq; using System.Collections.Generic; using System.IO; using System.Xml; Read More...
|
-
When developing C# programs in the functional programming style, you often need to dump out a collection to the console. Object dumper is a great tool to use for this. It is a sample that far too few developers know about. A functional transform typically takes the form of successive transformations: transform collection a => collection b => collection c => final collection. This is one of the main points of this topic in my Functional Programming Tutorial . When I commence developing such Read More...
|
-
Just as soon as I learn something, I blog it. This has a potential pitfall – sometimes I blog something and then learn that my approach was incorrect. But I’m not too awfully proud – I just blog again and tell you my new lessons learned. Nearly two years ago, I wrote some LINQ to XML code to use reflection take an object graph composed of anonymous types, and transform it into an XML tree. You can find that blog post here . In my ignorance, I wrote this code in the imperative style. This presents Read More...
|
|
|
|