English 中文(简体)
含有使用LINQPad的nes子的XML文件吗?
原标题:Query an XML file containing nested elements using LINQPad?

I m using LINQPad to query and visualize XML files with C#. For example:

var xml = XElement.Load(@"C:file.xml");
xml.Elements().Where(e => e.Element("trHeader").Element("trTickNum").Value == "1").Dump();

However, I d like run a query using SQL rather than C#.

是否有办法装上包含一些要素的XML,并使用LINQPad s 选择的表格?

最佳回答

That s not possible. The SQL option requires a database to be specified and is used to query that database. It s not possible to use SQL against an XML file which has its own hierarchy. What you could do is figure out a way to load the XML into SQL, or use the XML data type in SQL, then operate on the data entirely using SQL statements.

问题回答

这为我工作。

var xml = XElement.Load(@"C:AllTypesList.xml");
var list = xml.Elements().ToList();
var types = list.Where(x => x.Name == "XmlParamType").ToList();
types.Count().Dump();
types.GroupBy(t => t.Element("TypeName").Value).Count().Dump();




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签