1
     <?xml version="1.0" encoding="UTF-16"?>
      <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><GetXmlDocumentResponse xmlns="http://tempuri.org/">
       <GetXmlDocumentResult>
         <SNR_JO_POST xmlns=""> 
          <Sectors>   
           <LawyerName> abc</LawyerName>
            <ID>{B263A7B1-D766-4308-B486-C63BE66F4D74}</ID> 
           <Email>abc@gmail.com</Email>  
           </Sectors>  
        </SNR_JO_POST>
      </GetXmlDocumentResult>
    </GetXmlDocumentResponse>
   </soap:Body>
 </soap:Envelope>

以上是soap响应,我想从响应中获取LawyerName、ID和Email的值。我怎么能在我的 c# 代码中使用这个响应。

4

1 回答 1

1

您可以为此使用 Linq To Xml

var xDoc = XDocument.Parse(xmlstring);
var sectors = xDoc.Descendants("Sectors").FirstOrDefault();

var lawyerName = (string)sectors.Element("LawyerName");
var id = (string)sectors.Element("ID");
于 2013-08-06T20:34:59.033 回答