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 Query
- Loading controls from xml file
- How to loading XML files from a file
- Construct a list of wpf Hyperlink elements from an XML source file using Linq
- LINQ to XML - Load XML fragments from file
- Generate POCO objects from xml file
- Selecting elements from XML file using LINQ
- XLinq: Remove certain XElements from a xml file which are saved in a LIst<XElement>
- creating Linq to sqlite dbml from DbLinq source code
- Read from xml file to objectlist using Linq
- Reading values from xml file with Linq
- C# - Loading XML file in parts
- Lookup from xml file using linq
- Select Top n from XML File
- Retrieve the node values from XML file in LINQ and C#
- how to sum the values from an XML file based on certain criteria
- Get a list of ID Attributes from an XML File C#
- How to take value based on previous node from the given xml file
- Extracting specific data from an xml file using xdocument in C#
- "ADD" to DataGridView from XML file
- Use Separate Elements From XML File
- How to read multiple attributes from an xml file
- Name cannot begin with the '1' character, hexadecimal value 0x31. while reading from an xml file
- Loading data from XML Document throwing a NullReferenceException when using XDocument on Windows Phone 7
- Cant get list from received XML file
- Error while loading XML file using LINQ & Change the XML file after loading
- How to read data from xml file using linq to xml?
- Extracting Specific Items from an XML File
- How to Parse an XML file with Linq Lambda from Given Key
- C# - Load dictionary of Hashsets from an XML file using Linq
- How to bind dynamic multi listing data from xml file in windows phone 7?
More Query from same tag
- Select category tree in Entity Framework
- Linq to Entities with two tables
- How to select each first byte from bytes array
- Linq to Entity Join table with multiple OR conditions
- How do I apply a default IComparable<T> in a Linq OrderBy clause
- Linq - List of List
- How to check for the absence of any value in a list from a set server-side in LINQ? (SQL given)
- Left outer join in linq on three table
- Can I rewrite the following code using LINQ?
- Linq condition in list to get children elements of specific element
- LINQ list exclude item with latest datetime
- LINQ query throws an InvalidCastException?
- How to remove substring from all strings in a list in C# using LINQ
- How do I check if the user's input exists in the database table?
- Duplicate row in Seed Initializer
- Why is this Linq expression so much slower than the other?
- Apply OrderByDescending after GroupBy
- Linq query to match multiple parameters
- Return certain record based on criteria
- two tables with multiple joining conditions in lambda expressions
- ADO.NET - How to select multiple rows from a table ? (and count the number of the rows)
- Database Driven Nested Menu in ASP.Net LINQ
- Linq to nHibernate - exclude elements without child elements
- Why does 'return' and 'yield return' have the same behaviour in this example?
- 'List' does not contain a definition for 'Where'
- LinQ to objects GroupBy() by object and Sum() by amount
- How to get a dictionary with Linq where keys are met more than once?
- Aggregate on dictionary question
- Linq Include Select from Navigation Property
- Linq query to count field in datatable