2013-11-26 4 views
0

안녕하세요,이 XML 비누 응답은 webservice에서 오는 것입니다. xmlnodelist를 얻으려면 "IncomingApplications"아래에 Treatmenttype = 1이 있어야합니다. 부모 노드, 나는 지금 내가이 아이 즉 TreatmentType = IncomingApplications 노드를 반환하는 방식으로 위의 XPath를 변경하려면descendant와 name()을 사용하여 child node 값이 1 인 soap response로부터 xmlnodes를 얻습니다.

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

아래에이 코드를 사용하여 모든 "IncomingApplications"의 xmlnodelist를 얻을 수 acheived있다 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> 
+0

의견이 있으신 분? – Danyal

답변

0
다른 포럼에서

GOT의 답이 여기에 LINQ XML을 사용하여 솔루션보다는 XPath를

하여 XDocument의 xDoc = XDocument.Load ("SampleFile.xml");

string nameSpaceToSearch = @ "http://test.com/webservices/xyzConfigWS/InDataSet.xsd"; var result = (xName.Get ("IncomingApplications", nameSpaceToSearch) 여기서 xElement.Element (XName.Get ("TreatmentType", nameSpaceToSearch)). 값 == "1" 선택 xElement);