Unlike UfWebRequest the UfParse class deals directly with HTML. It can take either a HTML string or HTMLAgilityPack HTMLDocument object. The HTML string can be a full valid document or just a fragment of HTML code.
Using a HTMLAgilityPack HTMLDocument object can be useful for preprocessing documents as it has good XPath support.
using UfXtract; string html = "<div class=\"vcard\">"; html += "<span class=\"fn\">Glenn Jones</span>"; html += "</div>"; UfParse parser = new UfParse(); parser.Load(html, UfFormats.HCard()); if (parser.Data.Nodes.Count > 0) { UfDataToJson dataConvertor = new UfDataToJson(); Response.ContentType = "application/json"; Response.Write(dataConvertor.Convert(parser.Data, UfFormats.HCard())); }
© 2007-2010 Glenn Jones. All Rights Reserved.