0
为什么我的xmlNode节点总是以null结尾?我把它要求的命名空间。 下面是我已经加载的xml。用XPath选择单个xml节点w /名称空间Csharp
<?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>
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);
好像我做正确的一切。我给了它darn命名空间。但是节点总是空的。