I am trying to add a sub category to Messages in my xml statement Is there a way I can do this GroupMessages -> Message -> GroupMessage :
        var groups = xDoc.Descendants("Group")
             .Select(n => new
             {
                 GroupName = n.Element("GroupName").Value,
                 GroupHeader = n.Element("GroupHeader").Value,
                 TimeCreated = DateTime.Parse(n.Element("TimeAdded").Value),
                 Tags = n.Element("Tags").Value, 
                 Messages = n.Element("GroupMessages").Value
                 //line above
             })
             .ToList();
 In my method GroupMessages contains both MessageID and GroupMessage and it is listing both in my datagrid within the one container. So I tryed this but it lists nothing:
 Messages = n.Descendants("GroupMessages").Select(nd => nd.Element("GroupMessage").Value)
 My xml looks like this:
<Group>
 <TimeAdded>2012-04-27T10:23:50.7153613+01:00</TimeAdded>
 <GroupName>Group</GroupName>
 <GroupHeader>Header</GroupHeader>
 <GroupMessages>
 <Message>
 <MessageID>1</MessageID>
 <GroupMessage>Message</GroupMessage>
 <MessageGroup/>
 </Message>
 </GroupMessages>
 </Group>
 I have also tryed:
Messages = n.Descendants("GroupMessages").Select(nd => nd.Descendants("Message").Select(nde => nde.Element("GroupMessage").Value))
 To no avail?
 
No comments:
Post a Comment