Search Results

Search found 2 results on 1 pages for 'twreid'.

Page 1/1 | 1 

  • Retrieve nested list from XDocument with LINQ

    - by twreid
    Ok I want my link query to return a list of users. Below is the XML <section type="Users"> <User type="WorkerProcessUser"> <default property="UserName" value="Main"/> <default property="Password" value=""/> <default property="Description" value=""/> <default property="Group" value=""/> </User> <User type="AnonymousUser"> <default property="UserName" value="Second"/> <default property="Password" value=""/> <default property="Description" value=""/> <default property="Group" value=""/> </User> </section> And my current LINQ Query that doesn't work. doc is an XDocument var users = (from iis in doc.Descendants("section") where iis.Attribute("type").Value == "Users" from user in iis.Elements("User") from prop in user.Descendants("default") select new { Type = user.Attribute("type").Value, UserName = prop.Attribute("UserName").Value }); This does not work can anyone tell me what I need to fix? Here is my second attempt after fixing for the wrong property name. However this one does not seem to enumerate the UserName value for me when I try to use it or at least when I try to write it to the console. Also this returns 8 total results I should only have 2 results as I only have 2 users. (from iis in doc.Descendants("section") where iis.Attribute("type").Value == "Users" from user in iis.Elements("User") from prop in user.Descendants("default") select new { Type = user.Attribute("type").Value, UserName = (from name in prop.Attributes("property") where name.Value == "UserName" select name.NextAttribute.Value).ToString() });

    Read the article

  • Binding to an XElement

    - by twreid
    I need help binding to an XElement. Basically I am making a editor for certain elements in a web.config and I extract them as XElements and my View binds to a Collection of DataItems which has a property that contains my XElement. When I do Text="{Binding Path=Data, Mode=OneWay, NotifyOnSourceUpdated=True}"/> I get all the text of the Element, but If I try Text="{Binding Path=Data.Elements[], Mode=OneWay, NotifyOnSourceUpdated=True}"/> It doesn't work the TextBox is empty. I am trying to find a way to Template different sections dynamically to make them easier to edit instead of editing raw XMl.

    Read the article

1