Example #1
0
        private static void LoadXmlString()
        {
            StringBuilder errorMessageFormatter = new StringBuilder();

            errorMessageFormatter.AppendLine("<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\">");
            errorMessageFormatter.AppendLine("   <soap:Body>");
            errorMessageFormatter.AppendLine("      <soap:Fault>");
            errorMessageFormatter.AppendLine("         <faultcode>soap:Client</faultcode>");
            errorMessageFormatter.AppendLine("         <faultstring>Error message!</faultstring>");
            errorMessageFormatter.AppendLine("         <detail>Error details</detail>");
            errorMessageFormatter.AppendLine("      </soap:Fault>");
            errorMessageFormatter.AppendLine("   </soap:Body>");
            errorMessageFormatter.AppendLine("</soap:Envelope>");
            using (var xmlOperator = new XmlOperator())
            {
                xmlOperator.LoadFromString(errorMessageFormatter.ToString());
                var node = xmlOperator.GetXmlNode(x => x.Name == "faultcode");
                Console.WriteLine(xmlOperator.GetXmlNode(x => x.Name == "faultstring")?.FirstChild.Value);
                Console.WriteLine(xmlOperator.GetXmlNode(x => x.Name == "detail")?.FirstChild.Value);
                xmlOperator.SaveAs("D:\\TestExportFile\\TestXml.xml", true);
            }
        }