Attempting to get single value from XDocument, nothing appears to work

后端 未结 1 990
借酒劲吻你
借酒劲吻你 2021-01-28 07:31

I am just trying to get the value from MessageInfo.. Sender here is an excerpt of the xml. I just want the \"Senders\" value. I have tried many different things with XDocument,

相关标签:
1条回答
  • 2021-01-28 07:47

    You have a namespace that you have to use.

    XNamespace ns = "http://www.nwpp.org/eide";
    
    
    var query1 = doc.Descendants(ns +"MessageInfo").Select(s => new MessageInfo
                                 {
                                     SYSGENID = s.Element(ns +"SysGenID").Value,
                                     TIME_STAMP = s.Element(ns +"TimeStamp").Value,
                                     SENDER = s.Element(ns +"Sender").Value,
                                     RECEIVER = s.Element(ns +"Receiver").Value,
                                    ENTITY_CODE = s.Element(ns +"EntityCode").Value
                                 }).FirstOrDefault();
    
    0 讨论(0)
提交回复
热议问题