locked
get the xmlnodes from soap response whose child node value is 1 using descendant and name() RRS feed

  • Question

  • User905936915 posted

    Hi all I this xml soap response below coming from a webservice ,what I need is to get the xmlnodelist where Treatmenttype = 1 under "IncomingApplications" parent node , I have acheived to get a xmlnodelist of all "IncomingApplications" by use of this code below

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

    Now i want to change the above xpath in such a way that it return IncomingApplications nodes whose child i.e TreatmentType = 1 , any help pleas how to change the xpath to get the result ?

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




    Tuesday, November 26, 2013 12:07 PM

All replies

  • User905936915 posted

    any expert advice on the above please :)

    Wednesday, November 27, 2013 1:54 AM
  • User697462465 posted

    Hi danyal,

    If you want to get the xmlnodelist where Treatmenttype = 1 under "IncomingApplications" parent node. Please try to refer to the following code:

    XmlNodeList xmlnode = xmlDoc.DocumentElement.SelectNodes("{http://schemas.xmlsoap.org/soap/envelope/}Body").Descendants("IncomingApplications").Descendants("TreatmentType"))

    Hope it can help you.

    Best Regards,
    Terry Guo

    Wednesday, November 27, 2013 4:33 AM
  • User905936915 posted

    hi terry ,

    Thanks for yr respose :)

    however there is problem that the variable xmlDoc is of type XMLDocument , NOT of xdocument so the descendants function isnot available . i only want IncomingApplications nodelist who have TreatmentType value 1 and ignore the ones with 0 offcourse . in my XMLNodeList collection .

    Wednesday, November 27, 2013 5:12 AM