fork download
  1. using System;
  2. using System.Xml;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string xml1 = @"<s:Envelope xmlns:s='http://s...content-available-to-author-only...p.org/soap/envelope/' xmlns:u='http://d...content-available-to-author-only...n.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
  9. <s:Body>Body text!!!
  10. </s:Body>
  11. </s:Envelope>";
  12. string xml2 = @"<soapenv:Envelope xmlns:mes='MessageContracts' xmlns:req='RequestMessages' xmlns:soapenv='http://s...content-available-to-author-only...p.org/soap/envelope/'>
  13. <soapenv:Body>Body text 2!!!
  14. </soapenv:Body>
  15. </soapenv:Envelope>";
  16. XmlNode body1 = GetBody(xml1), body2 = GetBody(xml2);
  17.  
  18. Console.WriteLine(body1.InnerText);
  19. Console.WriteLine(body2.InnerText);
  20. }
  21.  
  22. private static XmlNode GetBody(string xml)
  23. {
  24. XmlDocument doc = new XmlDocument();
  25. doc.LoadXml(xml);
  26. XmlNamespaceManager nsm = new XmlNamespaceManager(doc.NameTable);
  27. nsm.AddNamespace("soap", "http://s...content-available-to-author-only...p.org/soap/envelope/");
  28. XmlNode body = doc.SelectSingleNode("/soap:Envelope/soap:Body", nsm);
  29.  
  30. return body;
  31. }
  32. }
Success #stdin #stdout 0.09s 35264KB
stdin
Standard input is empty
stdout
Body text!!!
                            
Body text 2!!!