2013-11-15 5 views
0

xmlNode 노드가 항상 null로 끝나는 이유는 무엇입니까? 내가 요청한 네임 스페이스를 넣었다. 다음은 내가로드 한 XML입니다. XPath Csharp를 사용하여 단일 xml 노드를 선택하십시오.

<?xml version="1.0" encoding="UTF-8"?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.enterprise.soap.sforce.com"> 
     <soapenv:Body> 
       <queryResponse> 
        <result> 
          <done>true</done> 
          <queryLocator xsi:nil="true"></queryLocator> 
          <records xsi:type="sf:Opportunity"> 
            <sf:Id xsi:nil="true"></sf:Id> 
            <sf:Account xsi:type="sf:Account"> 
              <sf:Id xsi:nil="true"></sf:Id> 
              <sf:Account_ID__c>AccountIdXXXX</sf:Account_ID__c> 
              <sf:Name>The Account Name</sf:Name> 
             </sf:Account> 
            <sf:OpportunityLineItems> 
              <done>true</done> 
              <queryLocator xsi:nil="true"></queryLocator> 
              <records xsi:type="sf:OpportunityLineItem"> 
               <sf:Id xsi:nil="true"></sf:Id> 
               <sf:Brand_Desc__c>Another Description</sf:Brand_Desc__c> 
               <sf:PricebookEntry xsi:type="sf:PricebookEntry"> 
                 <sf:Id xsi:nil="true"></sf:Id> 
                 <sf:Product2 xsi:type="sf:Product2"> 
                   <sf:Id xsi:nil="true"></sf:Id> 
                   <sf:Description>The Product Description</sf:Description> 
                  </sf:Product2> 
                </sf:PricebookEntry> 
               <sf:Product_Group_for_Storage_Sys__c>Some Descriptive Text</sf:Product_Group_for_Storage_Sys__c> 
               <sf:Product_Type_Formula__c>Enterprise</sf:Product_Type_Formula__c> 
               <sf:Product_Type_Text__c>Enterprise</sf:Product_Type_Text__c> 
               <sf:Product_Type__c>Enterprise</sf:Product_Type__c> 
               <sf:Product_code_for_analytics__c>Code Here</sf:Product_code_for_analytics__c> 
              </records> 
              <size>1</size> 
             </sf:OpportunityLineItems> 
            <sf:PartnerAccount xsi:type="sf:Account"> 
              <sf:Id xsi:nil="true"></sf:Id> 
              <sf:Account_ID__c>IDXXXX</sf:Account_ID__c> 
             </sf:PartnerAccount> 
            <sf:Partner_Account_Name__c>The Partner Name</sf:Partner_Account_Name__c> 
           </records> 
          <size>1</size> 
         </result> 
       </queryResponse> 
      </soapenv:Body> 
    </soapenv:Envelope> 

enter image description here

xmlSoapRequest.LoadXml(strResultString); 
      XmlNamespaceManager man = new XmlNamespaceManager(xmlSoapRequest.NameTable); 
      man.AddNamespace("sf", "urn:sobject.enterprise.soap.sforce.com"); 
      man.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/"); 



      XmlNode nodes = xmlSoapRequest.SelectSingleNode("/soapenv:Envelope/soapenv:Body/queryResponse/result/records/sf:Account/sf:Name", man); 

내가 제대로 최선을 다하고 있어요 것 같다

. 나는 그에게 네임 스페이스를 주었다. 그러나 노드는 항상 null로 끝납니다.

답변

0

더 간단한 XPath 문이 작동을 종료했습니다.

XmlNode nodes = xmlSoapRequest.SelectSingleNode("//sf:Account/sf:Name", man); 
관련 문제