Query XML File
Sorry if this has already been discussed. I could not find anything or I am just blind ;-)
Basically, I want to be able to take a xml type file and do queries against it.
So far I have not found a way to do this.
Sorry if this has already been discussed. I could not find anything or I am just blind ;-)
Basically, I want to be able to take a xml type file and do queries against it.
So far I have not found a way to do this.
Comments
From the FAQ:
https://www.linqpad.net/FAQ.aspx
Ok, I know I could spend a bunch of time and read through all of that and understand it. But in kind of a time crunch for this particular project.
In some code I wrote I created a class using XSD from an xml file I need to deal with (nessus scan files).
With that class I serialize from the xml file to the in memory class and I can go throughout the class and extract the data I need. But I have to do this in code and it takes time to figure what I need. I was hoping I could do something similar in LinqPad and play with different queries. Similar to the online Regex websites. Can this be done?
Well duh, just realized that what I want to do I am not dealing with xml but an in-memory class. So could I use LinqPad to serialize a xml file into a class and then play with the in-memory class?
Well yes you can use LINQPad to perform LINQ to Objects queries, but take a look at example Chapter 10 / Navigating and Querying / Querying Elements.
For your purpose you could replace
var bench = new XElement()
... withvar bench = XElement.Load(@"C:\Temp\file.xml");