public LoadHtmlAsXml ( string htmlUrl, |
||
htmlUrl | string | The requested URL, such as "http://Myserver/Mypath/Myfile.asp". |
writer | The XmlTextWriter to which you want to save to. | |
return | void |
public void LoadHtmlAsXml(string htmlUrl, XmlTextWriter writer)
{
HtmlDocument doc = Load(htmlUrl);
doc.Save(writer);
}
public static XmlDocument GetHtmlAsXml() { //Set up an in-memory stream to hold the HTML. MemoryStream stream = new MemoryStream(); XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8); //Grab HTML over the web and convert to XML. HtmlWeb web = new HtmlWeb(); web.LoadHtmlAsXml("http://haacked.com/Demos/screen.html", writer); //Now read from that in-memory stream //into a new XmlDocument class. XmlDocument xml = LoadFromStream(stream); return xml; }