How to best extract attribute values and element values with LINQ and C#

ptc187

New Member
Before i start this is my first post, so if there is something i have done wrong or not done please tell me and i'll edit my postI have a document which is formated as follows. \[code\]<Event xmlns='http://schemas.microsoft.com/win/2004/08/events/event'> <EventData> <Data Name='SubjectUserSid'>S-1-0-0</Data> <Data Name='SubjectUserName'>MACHINE$</Data> <Data Name='SubjectDomainName'>DOMAIN</Data> <Data Name='SubjectLogonId'>0x0</Data> <Data Name='TargetUserSid'>S-1-0-0</Data> <Data Name='TargetUserName'>username</Data> <Data Name='TargetDomainName'>TDname</Data> <Data Name='Status'>0x0</Data> <Data Name='FailureReason'>%%2313</Data> <Data Name='SubStatus'>0x0</Data> <Data Name='LogonType'>10</Data> </EventData></Event>\[/code\]I have a little problem comming up with something that can extract the values from the XML (both the attribute values and the corresponding element values). Do i need a statement for each of the attribute or can i return a list and just loop over the values? EDIT: The values needs to be extracted so i can send them to a database. I would like to try using LINQ for this, but Xpath might work aswell EDIT2: Thank you for three good answers, i don't have the req. reputation to upvote answers yet and i need to get to my dev machine before testing, but this really looks what im looking for :)
 
Top