score:1
If you are trying to iterate on all your controls in the XML and retreive the info, you should use XPath.
Here is an example:
XPathDocument Doc = new XPathDocument("yourfile.xml");
XPathNavigator navigator = Doc.CreateNavigator();
XPathNodeIterator iterator = navigator.Select("/controls/*");
while (iterator.MoveNext())
{
System.Diagnostics.Debug.Print(iterator.Current.Content);
System.Diagnostics.Debug.Print(iterator.Current.Location);
}
score:2
Using LINQ: (For ForeColor/LinkColor check for null)
XDocument loaded = XDocument.Load(@"C:\XMLFile1.xml");
var q = from c in loaded.Descendants().Descendants()
select new
{
content = c.Attribute("Content"),
location = c.Attribute("Location"),
size = c.Attribute("Size"),
foreColor = c.Attribute("ForeColor"),
linkColor = c.Attribute("LinkColor")
};
foreach (var controlItem in q)
Console.WriteLine("Control content = {0}", controlItem.content);
Source: stackoverflow.com
Related Articles
- Loading controls from xml file
- creating Linq to sqlite dbml from DbLinq source code
- How to loading XML files from a file
- Construct a list of wpf Hyperlink elements from an XML source file using Linq
- c# Linq or code to extract groups from a single list of source data
- How to create a csv file from List<String[]>
- loading a full hierarchy from a self referencing table with EntityFramework.Core
- LINQ to XML - Load XML fragments from file
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Accessing Results View from variable in code
- Generating the Shortest Regex Dynamically from a source List of Strings
- Generate POCO objects from xml file
- Why is my code doing lazy loading even after I turned it off at every possible point?
- How to SELECT from any spreadsheet in Excel File using OleDbDataAdapter
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- Extracting data from CSV file (fusion table and kml workaround)
- How to pass LinQ Expressions from F# to C# code
- How to read File names recursively from subfolder using LINQ
- How to read from a Text File Faster/Smarter?
- Using LINQ to delete an element from a ObservableCollection Source
- can my code improve from using LINQ?
- How to prevent Entity Framework from loading all child objects
- How does linq actually execute the code to retrieve data from the data source?
- LINQ Source Code Available
- C#/.NET string magic to remove comment lines from text file input?
- .NET 4 Code Contracts: "requires unproven: source != null"
- Removing a single item from an enumerable source when the items are equal
- How to get keys and values from Appsettings of Config file in Linq
- Selecting elements from XML file using LINQ
- Performance issue loading data from CRM
- LINQ query on child list
- Task.Any() Call task twice
- How to Select new model list after GroupBy mothod in Linq?
- Null checker in LINQ
- LINQ Query Help
- C# - How to loop back around after assigning integer IDs from a collection?
- linq query on list id's
- How to find a specific element in a List
- Return all elements except for a specific element that also has no value
- How to filter entities based on 2nd degree relationship
- How to include selected value in populated drop-down list
- Can I Use The Same Linq Code to Query for Different Conditions?
- How to translate a query with an EntityState and a value from Entity Framework 5 to 6?
- Get Sums of All Instances of an Id From Two Tables
- something wrong reading XML LINQ
- Linq results different than the sql result
- Implement EntitySet as IList
- How to use the value from a property accessor LINQ expression in a Contains LINQ expression?
- How to pass multiple properties to Expression<Func<TEntity, IEnumerable<TProperty>>>
- How can i convert my Sql codes to Linq?