I am trying to save the HTML document as XML and have it loaded into an XMLdocument for manipulation. I have saved the document to a memory stream and am trying to load that to an XML document but it does not work. Something about and unclosed literal. If I
save the document to an xml file and then load it it works fine.
Here is what I have.
MemoryStream myStream = new MemoryStream();
HtmlDocument doc = new HtmlDocument();
doc.OptionOutputAsXml = true;
doc.OptionOutputOptimizeAttributeValues = true;
MemoryStream loadStream = new MemoryStream();
XmlDocument myXML = new XmlDocument();
byte byteArray = myStream.ToArray();
loadStream.Write(byteArray, 0, byteArray.Length);
loadStream.Position = 0;
This seemed to work for me:
public static XmlDocument getXmlDoc(String HTML)
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.OptionOutputAsXml = true;
System.IO.MemoryStream stream = new System.IO.MemoryStream();
XmlTextWriter xtw = new XmlTextWriter(stream, null);
// Load the content into the writer
// Rewind the memory stream
stream.Position = 0;
XmlDocument xmlDoc = new XmlDocument();
Would it be possible to help me how to make your program work?
And I am not sure the code of "htmlDoc.LoadHtml(HTML)" .Do it can load specific file of html?
Thank you for your kindly help.