Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:05:26+00:00 2026-05-23T09:05:26+00:00

I am using HTML Agility Pack to parse and HTML document, make a change

  • 0

I am using HTML Agility Pack to parse and HTML document, make a change to a node, and then save the HTML document. I would like to save the document to memory so I can write the HTML out as a string later in the application. My current implementation always returns a string == “”. I can see that the HtmlDocument object is not empty when debugging. Can someone provide some insight?

private string InitializeHtml(HtmlDocument htmlDocument)
    {
        string currentUserName = User.Identity.Name;
        HtmlNode scriptTag = htmlDocument.DocumentNode.SelectSingleNode("//script[@id ='HwInitialize']");
        scriptTag.InnerHtml = 
            string.Format("org.myorg.application = {{}}; org.myorg.application.init ={{uid:\"{0}\", application:\"testPortal\"}};",currentUserName);

        MemoryStream memoryStream = new MemoryStream();
        htmlDocument.Save(memoryStream);
        StreamReader streamReader = new StreamReader(memoryStream);
        return streamReader.ReadToEnd();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:05:27+00:00Added an answer on May 23, 2026 at 9:05 am

    Try

    memoryStream.Seek(0, System.IO.SeekOrigin.Begin)
    

    Before creating the StreamReader and calling ReadToEnd()

    The stream pointer is likely getting left at the end of the stream by the Save method (it’s best practise for a component to do this – in case you want to append more data to the stream) therefore when you call ReadToEnd, it’s already at the end and nothing gets read.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using html agility pack to parse html tabular information . Now there
I am using HTML Agility Pack to parse html content. I am using parsing
I want to parse the html table using html agility pack. I want to
Using the html agility pack; how would I extract an html fragment from a
I'm using HTML Agility Pack to parse and transform a HTML file, but I
I'm using the html agility pack to read the contents of my html document
I am using the Html Agility Pack to parse some html and am having
I would like to parse an HTML table and disaply contents using XML to
Why html agility pack is used to parse the information from the html file
I am trying to stop XSS attack so I am using html agility pack

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.