public static void LinqCompare(XmlDocument doc, string html, ParserOptions options = null) { #if !net20 // Linq check XDocument xdoc = XHtmlLoaderX.LoadHtml(html, options); string xdocOuterXml = xdoc.ToString(SaveOptions.DisableFormatting); Console.WriteLine(xdocOuterXml); Assert.AreEqual(doc.OuterXml, xdocOuterXml); #endif }
static string[] XHtmlKit_Linq_ParseAndSearch(string html, string xpath = null) { List <string> searchResults = new List <string>(); XDocument doc = XHtmlLoaderX.LoadHtml(html); if (xpath != null) { var results = doc.XPathSelectElements(xpath); foreach (XElement node in results) { string result = node.Value; searchResults.Add(result); } } return(searchResults.ToArray()); }
public static void LoadHtml(this XDocument doc, string html) { XHtmlLoaderX.LoadHtml(doc, new StringReader(html), new ParserOptions()); }