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 8732789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:30:16+00:00 2026-06-13T09:30:16+00:00

Consider the following HTML fragment ( _ is used for whitespace): <head> … <link

  • 0

Consider the following HTML fragment (_ is used for whitespace):

<head>
    ...
    <link ... ___/>
    <!-- ... -->
    ...
</head>

I’m using Html Agility Pack (HAP) to read HTML files/fragments and to strip out links. What I want to do is find the LINK (and some other) elements and then replace them with whitespace, like so:

<head>
    ...
    ____________
    <!-- ... -->
    ...
</head>

The parsing part seems to be working so far, I get the nodes I’m looking for. However, HAP tries to fix the HTML content while I need everything to be exactly the same, except for the changes I’m trying to make. Plus, HAP seems to have quite a few bugs when it comes to writing back content that was read in previously, so the approach I want to take is let HAP parse the input and then I go back to the original input and replace content that I don’t want.

The problem is, HtmlNode doesn’t seem to have an input length property. It has StreamPosition which seems to indicate where reading of the node’s content started within the input but I couldn’t find a length property that’d tell me how many characters were consumed to build the node.

I tried using the OuterHtml propety but, unfortunately, HAP tries to fix the LINK by removing the ___/ part (a LINK element is not supposed to be closed). Because of this, OuterHtml.Length returns the wrong length.

Is there a way in HAP to get this information?

  • 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-06-13T09:30:18+00:00Added an answer on June 13, 2026 at 9:30 am

    I ended up modifying the code of HtmlAgilityPack to expose a new property that returns the private _outerlength field of HtmlNode.

    public virtual int OuterLength
    {
        get
        {
            return ( _outerlength );
        }
    }
    

    This seems to be working fine so far.

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

Sidebar

Related Questions

Consider the following html snippet <!DOCTYPE html> <html> <head> <script type=text/javascript src=http://code.jquery.com/jquery-1.4.2.js ></script> <script
Consider the following code: index.html <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head>
Consider the following HTML: (Written for Google Chrome) <html> <head> <script language=javascript> function AddToIFrame(){
Consider the following HTML: <!DOCTYPE html> <html> <head> <title></title> </head> <body> <div style=border-style: solid;
Consider the following html document: <!DOCTYPE html> <html> <head> <script type=text/javascript> alert(Hello) </script> </head>
Consider the following HTML snippet: <p>Space&nbsp;Test</p> When this HTML is used in a web
Consider the following rudimentary html code block: <!doctype html> <html> <head> <meta charset=utf-8> <title>iPad
Consider following DOM fragment: <div id=div-1>foo</div> <div id=div-2>bar</div> Is it possible to insert HTML
Consider the following Html file: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head>
Consider the following: HTML <div class=info_bubble> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.

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.