|
|
Browse by Tags
All Tags » 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...
|
-
[Blog Map] A convenient way to explore Open XML markup is to create a small document, modify the document slightly in the Word user interface, save it, and then compare it with the Open XML Diff utility that comes with the Open XML SDK V2 . However, Word adds extraneous elements and attributes that enable merging of two documents that have forked. These elements and attributes show up as changed, and obscure the differences that we’re looking for. An easy way to deal with this is to remove these 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...
|
-
[Blog Map] Merging multiple word processing documents into a single document is something that many people want to do. An application built for attorneys might assemble selected standard clauses into a contract. An application built for book publishers can assemble chapters of a book into a single document. This post explains the semantics of the altChunk element, and provides some code using the Open XML SDK that shows how to use altChunk. Instead of using altChunk, you could write a program to Read More...
|
-
I was in a meeting this afternoon, and someone said that they wished that there was a comparison of XPath expressions and LINQ to XML queries. Well, this already exists in the LINQ to XML document. The topic title is LINQ to XML for XPath Users . If you already speak XPath, this can provide a head-start on learning how to write LINQ to XML queries. Read More...
|
-
Data-bound content controls are a powerful and convenient way to separate the semantic business data from the markup of an Open XML document. After binding content controls to custom XML, you can query the document for the business data by looking in the custom XML part rather than examining the markup. Querying custom XML is much simpler than querying the document body. However, it’s a little bit involved to create data-bound content controls (but only a little bit). But there is a trick we can 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...
|
-
When I was writing the LINQ to XML documentation , Ralf Lämmel was the program manager for LINQ to XSD , an incubation project in the data programmability group at Microsoft. Ralf really helped me a lot in those days, both with questions on LINQ to XML, and questions around functional programming. It was in email exchanges with Ralf that the lights started going on for me around functional programming. So far, LINQ to XSD hasn't become a supported product (I don't know the product team's plans around 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...
|
|
|
|