XDocument/xNamespace

发布于 2024-11-17 07:56:27 字数 1631 浏览 3 评论 0原文

<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>

如何获取Success的值?

<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>

How to get the value of <ns4:ApplicationStatus>Success</ns4:ApplicationStatus>?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别靠近我心 2024-11-24 07:56:27
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;
var xdocument = XDocument.Load(@"C:\1.xml");
var result = xdocument.Descendants(XName.Get("ApplicationStatus", "urn:Allscripts:Hub:PatientMsg")).First().Value;

Or

var result = xdocument.XPathSelectElement("//ns4:ApplicationStatus", xdocument.Root.CreateNavigator()).Value;
转角预定愛 2024-11-24 07:56:27
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;
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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文