C# XDocument/xNamespace 229dd2a9-9c6c-49c5-aebe-3210C7B000DF2 消息 收到 2011-06-23T22:06:52 接收集线器信息 0906b2b2-e690-459f-82f0-82d6c33e6e03 成功 成功 2011-06-23T22:06:52 接收集线器接受的消息。 使用RxPrescriptionService WCF服务交付
如何获得C# XDocument/xNamespace 229dd2a9-9c6c-49c5-aebe-3210C7B000DF2 消息 收到 2011-06-23T22:06:52 接收集线器信息 0906b2b2-e690-459f-82f0-82d6c33e6e03 成功 成功 2011-06-23T22:06:52 接收集线器接受的消息。 使用RxPrescriptionService WCF服务交付,c#,linq-to-xml,xnamespace,C#,Linq To Xml,Xnamespace,如何获得成功的价值 或 可能重复的 <AllscriptsMessageEnvelope xmlns="http://Allscripts.com/UAI/Schemas/2010/02/15" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="urn:Allscripts:Hub:PatientMsg" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> &l
成功的价值
或
可能重复的
<AllscriptsMessageEnvelope xmlns="http://Allscripts.com/UAI/Schemas/2010/02/15" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="urn:Allscripts:Hub:PatientMsg" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MessageDispatchHeader>
<ID xmlns="">229dd2a9-9c6c-49c5-aebe-3210c7b00df2 </ID>
<Noun xmlns="">Message</Noun>
<Verb xmlns="">Received</Verb>
<TimeStamp xmlns="">2011-06-23T22:06:52</TimeStamp>
<Description xmlns="">Rx Hub Message</Description>
<Originator xmlns="">
<OriginatorName />
</Originator>
<Destination xmlns="">
<SendToName />
</Destination>
</MessageDispatchHeader>
<EntityContext />
<MessageContent xmlns="">
<ns4:MessageProcessed>
<ns4:ReplyToMessageID>0906b2b2-e690-459f-82f0-82d6c33e6e03</ns4:ReplyToMessageID>
<ns4:TransportStatus>Success</ns4:TransportStatus>
<ns4:ApplicationStatus>Success</ns4:ApplicationStatus>
<ns4:Datetime>2011-06-23T22:06:52</ns4:Datetime>
<ns4:Comment>Message Accepted by Rx Hub.</ns4:Comment>
<ns4:AdditionalDetails>
<ns4:AdditionalDetail>Delivered using RxPrescriptionService WCF Service</ns4:AdditionalDetail>
</ns4:AdditionalDetails>
</ns4:MessageProcessed>
</MessageContent>
</AllscriptsMessageEnvelope>
var xdocument = XDocument.Load(@"C:\1.xml");
var result = xdocument.Descendants(XName.Get("ApplicationStatus", "urn:Allscripts:Hub:PatientMsg")).First().Value;
var result = xdocument.XPathSelectElement("//ns4:ApplicationStatus", xdocument.Root.CreateNavigator()).Value;
XNamespace ns4 = "urn:Allscripts:Hub:PatientMsg";
XDocument doc = XDocument.Load("yourFileName.xml");
string applicationStatusValue = doc.Root.Element("MessageContent")
.Element(ns4 + "MessageProcessed")
.Element(ns4 + "ApplicationStatus")
.Value;