0

こんにちは、この xml ソープ応答は Web サービスからのものです。必要なのは、「IncomingApplications」親ノードの下で Treatmenttype = 1 の xmlnodelist を取得することです。以下のこのコードを使用して、すべての「IncomingApplications」の xmlnodelist を取得することができました。

  XmlNodeList xmlnode = xmlDoc.DocumentElement.SelectNodes("//soap:Body/descendant::*[name()='IncomingApplications']", nsmgr);

ここで、上記の xpath を、子の IncomingApplications ノード、つまり TreatmentType = 1 を返すように変更したいのですが、結果を取得するために xpath を変更する方法を教えてください。

 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <GetIncomingApplicationsDataResponse xmlns="http://test.com/webservices/service">
      <GetIncomingApplicationsDataResult>
        <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
          <InDataSet xmlns="http://test.com/webservices/xyzConfigWS/InDataSet.xsd">
            <IncomingApplications diffgr:id="InApp1" msdata:rowOrder="0">
              <SiteName>Test</SiteName>
              <QueueId>1501</QueueId>
              <ApplicationId>3362546</ApplicationId>
              <CountryId>1</CountryId>
              <HoldingQueueId>33625460</HoldingQueueId>
              <CallbackQueueId>3366025</CallbackQueueId>
              <TreatmentType>0</TreatmentType>
              <UnderThresholdQueueId>33625460</UnderThresholdQueueId>
              <IVRGroup>IVR</IVRGroup>
            </IncomingApplications>
            <IncomingApplications diffgr:id="InApp2" msdata:rowOrder="1">
              <SiteName>Test</SiteName>
              <QueueId>1501</QueueId>
              <ApplicationId>3362600</ApplicationId>
              <CountryId>1</CountryId>
              <HoldingQueueId>33626000</HoldingQueueId>
              <CallbackQueueId>3366025</CallbackQueueId>
              <TreatmentType>0</TreatmentType>
              <UnderThresholdQueueId>33626000</UnderThresholdQueueId>
              <IVRGroup>IVR</IVRGroup>
            </IncomingApplications>
            <IncomingApplications diffgr:id="InApp3" msdata:rowOrder="2">
              <SiteName>Test</SiteName>
              <QueueId>1501</QueueId>
              <ApplicationId>3362769</ApplicationId>
              <CountryId>1</CountryId>
              <HoldingQueueId>33627690</HoldingQueueId>
              <CallbackQueueId>3366025</CallbackQueueId>
              <TreatmentType>1</TreatmentType>
              <UnderThresholdQueueId>33627690</UnderThresholdQueueId>
              <IVRGroup>IVR</IVRGroup>
            </IncomingApplications>
        </diffgr:diffgram>
      </GetIncomingApplicationsDataResult>
    </GetIncomingApplicationsDataResponse>
  </soap:Body>
</soap:Envelope>
4

1 に答える 1

0

他のフォーラムから回答を得ました。xpath ではなく linq to xml を使用したソリューションを次に示します。

XDocument xDoc = XDocument.Load("SampleFile.xml");

文字列 nameSpaceToSearch = @" http://test.com/webservices/xyzConfigWS/InDataSet.xsd "; var result = (xDoc.Descendants(XName.Get("IncomingApplications", nameSpaceToSearch)) の xElement から) where xElement.Element(XName.Get("TreatmentType", nameSpaceToSearch)).Value == "1" select xElement);

于 2013-11-27T13:49:58.377 に答える