7.10. Convert an XML File to a Delimited File (and Vice Versa)

Problem

You need to convert the contents of an XML file to a text file with delimited fields or convert a text file with delimited fields to an XML file.

Solution

To transform XML data to a delimited text file, use a LINQ query to retrieve and data and project it into an appropriate format. To transform the delimited text file to an XML tree, read and parse the data while creating the necessary XML nodes using XML literals and embedded expressions.

How It Works

LINQ to XML gives you the power to quickly and easily transform XML data to and from different formats by altering or transforming XML nodes within a LINQ query. If you need to transform the data in an existing XML tree into ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.