Read Soap Message using C#

前端 未结 4 1226
傲寒
傲寒 2020-12-03 14:59

  
    

        
4条回答
  •  一整个雨季
    2020-12-03 15:26

    BookHotelResponse is in the namespace urn:schemas-test:testgate:hotel:2012-06 (the default namespace in the sample xml) so you need to provide that namespace in your queries:

    XmlDocument document = new XmlDocument(); 
    document.LoadXml(soapmessage);  //loading soap message as string 
    XmlNamespaceManager manager = new XmlNamespaceManager(document.NameTable); 
    
    manager.AddNamespace("d", "http://someURL"); 
    manager.AddNamespace("bhr", "urn:schemas-test:testgate:hotel:2012-06"); 
    
    XmlNodeList xnList = document.SelectNodes("//bhr:bookHotelResponse", manager); 
    int nodes = xnList.Count; 
    
    foreach (XmlNode xn in xnList) 
    { 
        Status = xn["d:bookingStatus"].InnerText; 
    } 
    

提交回复
热议问题