how to read each xml node from results

NekkidBootie

New Member
Morning,I am have some XML which is being returned, and i need to read each of the result nodes, and then put them into my DB.So SKU, ResultMessageCode would be stored. I need to only pull these out if ResultCode is marked as an error.\[code\] <Message> <MessageID>1</MessageID> <ProcessingReport> <DocumentTransactionID>123456789</DocumentTransactionID> <StatusCode>Complete</StatusCode> <ProcessingSummary> <MessagesProcessed>2</MessagesProcessed> <MessagesSuccessful>0</MessagesSuccessful> <MessagesWithError>2</MessagesWithError> <MessagesWithWarning>0</MessagesWithWarning> </ProcessingSummary> <Result> <MessageID>1</MessageID> <ResultCode>Error</ResultCode> <ResultMessageCode>90205</ResultMessageCode> <ResultDescription>Some Text Here</ResultDescription> <AdditionalInfo> <SKU>12345</SKU> </AdditionalInfo> </Result> <Result> <MessageID>2</MessageID> <ResultCode>Error</ResultCode> <ResultMessageCode>90205</ResultMessageCode> <ResultDescription>Some Text Here</ResultDescription> <AdditionalInfo> <SKU>67890</SKU> </AdditionalInfo> </Result> </ProcessingReport></Message>\[/code\]I found this elsewhere on Stackoverflow, and think this maybe what i am after.\[code\] foreach (XmlNode chldNode in node.ChildNodes) { **//Read the attribute Name** if (chldNode.Name == Employee) { if (chldNode.HasChildNodes) { foreach (XmlNode item in node.ChildNodes) { } } } }\[/code\]Am i assuming correctly here, and would need to use something similar? however the XML from the above sample was slightly smaller.Thanks in advance.
 
Back
Top