当前位置: 首页 > 工具软件 > SGMLReader > 使用案例 >

Html Agility Pack/SgmlReader 解析html

毕宇
2023-12-01
Html Agility Pack/SgmlReader 解析html

HtmlDocument htmlDoc = new HtmlDocument(); //输出成xml格式 htmlDoc.OptionOutputAsXml = true; / 加载html内容 htmlDoc.LoadHtml(@"<html><body> <table> <tr> <td>dafd</td> <td> </tr> </table> </body></html>"); // 将输出结果保存到字符串流中 StringBuilder sbXml = new StringBuilder(); StringWriter sw = new StringWriter(sbXml); htmlDoc.Save(sw); Console.WriteLine(sbXml.ToString()); StringBuilder sbXml = new StringBuilder(); StringWriter sw = new StringWriter(sbXml); XmlTextWriter tw = new XmlTextWriter(sw); HtmlWeb htmlWeb = new HtmlWeb(); htmlWeb.LoadHtmlAsXml("http://htmlagilitypack.codeplex.com/", tw); Console.WriteLine(sbXml.ToString());

  

转载于:https://www.cnblogs.com/ok519/p/3555459.html

 类似资料: