0

Is it possible to economize the loop in the following code snippet (element is of type XElement)?

TreeViewItem root = new TreeViewItem();

foreach (XAttribute attr in element.Attributes()) {
     root.HtmlAttributes.Add(attr.Name.ToString(),attr.Value);
}

So that I could pass lists as parameter to the function something like:

root.HtmlAttributes(element.Attributes.Names,element.Attributes.Values)
StellaMaris
  • 877
  • 2
  • 12
  • 29
  • There is [MoreLinq](https://code.google.com/p/morelinq/) with the [`ForEach` extension](https://code.google.com/p/morelinq/source/browse/MoreLinq/ForEach.cs). – Uwe Keim Nov 19 '15 at 14:35
  • See webpage :http://stackoverflow.com/questions/28976601/recursion-parsing-xml-file-with-attributes-into-treeview-c-sharp – jdweng Nov 19 '15 at 14:49
  • XElement is part of an XML document but your code is using HTML. They are not the same. I'm confused!!! – jdweng Nov 19 '15 at 16:29

0 Answers0