How to read this xml LINQ To XML?Ramesh S10yAsked Nov 19, 2015, 3:51 AM1kVisual Basic .NETEnterprise1
Manas Mohapatra10y agoPosted Nov 19, 2015, 5:37 AMAccepted answerTry with below code: string Sender = xelement.Descendants("Header").Elements("Sender").FirstOrDefault().Value.ToString();string Receiver = xelement.Descendants("Header").Elements("Receiver").FirstOrDefault().Value.ToString();string Count = xelement.Descendants("Header").Elements("Count").FirstOrDefault().Value.ToString(); In my previous answer you are getting error because you provided wrong XML conent in your question. After I got your full code I analyse that it needs to re-write. Hope this helps. +2
Manas Mohapatra10y agoPosted Nov 19, 2015, 4:57 AMFirst make little correct in XML data because it is missing "C" in Count tag. Enterprise1 Secondly it is not needed to fetch the root tag to get the value. See below code: XElement xelement = XElement.Load("D:\\Enterprise XML.xml"); string Sender = xelement.Element("Sender").Value;+1
Ramesh S10y agoPosted Nov 19, 2015, 4:43 AMXml fileEnterprise1 I have this code XElement xelement = XElement.Load("D:\\Enterprise XML.xml"); string Sender = xelement.Element("Header").Element("Sender").Value;I want output Sender null or empty but error throw+1
Manas Mohapatra10y agoPosted Nov 19, 2015, 3:55 AMWhat is your problem you are facing, please describe it more.0
Manas MohapatraPosted Nov 19, 2015, 5:37 AM
Ramesh SPosted Nov 19, 2015, 5:42 AM
Ramesh SPosted Nov 19, 2015, 5:09 AM
Manas MohapatraPosted Nov 19, 2015, 4:57 AM
Ramesh SPosted Nov 19, 2015, 4:43 AM
Manas MohapatraPosted Nov 19, 2015, 3:55 AM