public XmlDocument UnitTestResponse() { XNamespace soapNamespace = "http://www.w3.org/2001/12/soap-envelope"; XNamespace ns = "http://lowell.co.uk"; var response = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XElement(soapNamespace + "Envelop", new XAttribute(XNamespace.Xmlns + "S", soapNamespace.NamespaceName), new XElement(soapNamespace + "Body", new XElement(ns + "fnPointResponse", new XAttribute(XNamespace.Xmlns + "ns", ns.NamespaceName), new XElement("return", new XElement("invocation", new XElement("invocationDate")), new XElement("data", new XElement("account"), new XElement("customer")), new XElement("decision", new XElement("account"), new XElement("customer"), new XElement("actions", new XElement("accountAction", new XElement("action", "Repcode Move"), new XElement("sendToLima", false)), new XElement("accountAction", new XElement("action", "Send Letter"), new XElement("sendToLima", true))))))))); return(XmlConversion.ToXmlDocument(response)); }
public List <AccountAction> GetAccountActions(XmlDocument response) { var data = XmlConversion.ToXDocument(response); var accountActions = data.Descendants("actions1") .Elements() .Select(x => new AccountAction { Action = x.Element("action") != null ? x.Element("action").Value : null, SendToLima = Convert.ToBoolean(x.Element("sendToLima").Value) }) .ToList(); return(accountActions); }
public WordDocument GetDocument(string htmlText) { WordDocument document = null; MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream, System.Text.Encoding.Default); htmlText = htmlText.Replace("\"", "'"); XmlConversion XmlText = new XmlConversion(htmlText); XhtmlConversion XhtmlText = new XhtmlConversion(XmlText); writer.Write(XhtmlText.ToString()); writer.Flush(); stream.Position = 0; document = new WordDocument(stream, FormatType.Html, XHTMLValidationType.None); return(document); }
public WordDocument GetDocument(string htmlText) { WordDocument document = null; MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream, System.Text.Encoding.Default); htmlText = htmlText.Replace("\"", "'"); var oldSrc = getArray(htmlText); // get the copy of the src attributes in img tag and store in an array XmlConversion XmlText = new XmlConversion(htmlText); XhtmlConversion XhtmlText = new XhtmlConversion(XmlText); var text = XhtmlText.ToString(); var newSrc = getArray(text); // get the modified src attributes for replacing and store in another array for (int i = 0; i < oldSrc.Count(); i++) // replace the modified src attributes with original { text = text.Replace(newSrc[i], oldSrc[i]); } writer.Write(text); writer.Flush(); stream.Position = 0; document = new WordDocument(stream, FormatType.Html, XHTMLValidationType.None); return(document); }