Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: HTML and MemoryStream

$
0
0
Can anyone find a reason for this code not working? That is, for the stream returning empty?
IList<QuestionDefinitions> questiondefs = new List<QuestionDefinitions>();

                QuestionDefinitions questdef = new QuestionDefinitions();
                questdef.OriginalTxt = Server.HtmlEncode(@"<dd> [] text...text...text <dd> [] text...text");

                HtmlDocument doc = new HtmlDocument();
                //doc.OptionFixNestedTags = true;
                //doc.OptionWriteEmptyNodes = true;
                doc.OptionDefaultStreamEncoding = Encoding.UTF8;

                doc.LoadHtml(@"<table><tr><td><dd>text...text...text <dd>text...text</td></tr></table>");

                Stream htmlStream = new MemoryStream();

                doc.Save(htmlStream);

                StreamReader streamReader = new StreamReader(htmlStream);

                questdef.NewTxt = streamReader.ReadToEnd().Trim();

                questdef.IsSame = questdef.OriginalTxt == questdef.NewTxt ? true : false;

                questiondefs.Add(questdef);

                this.lblCount.Text = questiondefs.Count.ToString();
                dgQuestionDefs.DataSource = questiondefs;
                dgQuestionDefs.DataBind();
I tried including moving the position of the stream to 0, but that had no effect.

Your expedient assistance is greatly appreciated.

Thanks...Chris

Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>