Converting a CSV file to XML using LinQ# DotNet - 窗口里的风景
c*t
1 楼
using System;
using System.Query;
using System.Xml.XLinq;
using System.IO
namespace LinqToXmlSample.FlatFileToXml
{
class Program
{
static void main(string [] args)
{
XElement xml =
new XElement("books",
from line in File.ReadAllLines("books.txt")
where !line.StartsWith("#")
let items = line.Split(',')
select new XElement("book",
new XElement("title", items[1]),
new XElement("authors",
from authorFullName in items[2].Split(';')
let authorNameParts =
using System.Query;
using System.Xml.XLinq;
using System.IO
namespace LinqToXmlSample.FlatFileToXml
{
class Program
{
static void main(string [] args)
{
XElement xml =
new XElement("books",
from line in File.ReadAllLines("books.txt")
where !line.StartsWith("#")
let items = line.Split(',')
select new XElement("book",
new XElement("title", items[1]),
new XElement("authors",
from authorFullName in items[2].Split(';')
let authorNameParts =