<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Head>
      <h:talkId s:mustknow="1" xmlns:h="urn:schemas-test:testgate:hotel:2012-06">sfasfasfasfsfsf/h:talkidId>
   </s:Head>
   <s:Body>
      <bookHotelResponse xmlns="urn:schemas-test:testgate:hotel:2012-06" xmlns:d="http://someURL" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

         <d:bookingReference>123456</d:bookingReference>
         <d:bookingStatus>successful</d:bookingStatus>
         <d:price xmlns:d="moreURL">
            <b:total>105</b:total>
         </d:price>
      </bookHotelResponse>
   </s:Body>
</s:Envelope>

want to read the bookingStatus and total from the soap message above using xmldocument and xpath but does not work i am using the code below

            XmlDocument document = new XmlDocument();
            document.LoadXml(soapmessage);  //loading soap message as string
            XmlNamespaceManager manager = new XmlNamespaceManager(document.NameTable);

            manager.AddNamespace("d", "http://someURL");

            XmlNodeList xnList = document.SelectNodes("//bookHotelResponse", manager);
            int nodes = xnList.Count;

            foreach (XmlNode xn in xnList)
            {
                Status = xn["d:bookingStatus"].InnerText;
            }

Recommended Answers

All 2 Replies

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.