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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:08:35+00:00 2026-05-21T16:08:35+00:00

I recently started experimenting with the HtmlAgilityPack. I am not familiar with all of

  • 0

I recently started experimenting with the HtmlAgilityPack. I am not familiar with all of its options and I think therefor I am doing something wrong.

I have a string with the following content:

string s = "<span style=\"color: #0000FF;\"><</span>";

You see that in my span I have a ‘less than’ sign.
I process this string with the following code:

HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(s);

But when I do a quick and dirty look in the span like this:

htmlDocument.DocumentNode.ChildNodes[0].InnerHtml

I see that the span is empty.

What option do I need to set maintain the ‘less than’ sign. I already tried this:

htmlDocument.OptionAutoCloseOnEnd = false;
htmlDocument.OptionCheckSyntax = false;
htmlDocument.OptionFixNestedTags = false;

but with no success.

I know it is invalid HTML. I am using this to fix invalid HTML and use HTMLEncode on the ‘less than’ signs

Please direct me in the right direction. Thanks in advance

  • 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-21T16:08:35+00:00Added an answer on May 21, 2026 at 4:08 pm

    The Html Agility Packs detects this as an error and creates an HtmlParseError instance for it. You can read all errors using the ParseErrors of the HtmlDocument class. So, if you run this code:

        string s = "<span style=\"color: #0000FF;\"><</span>";
        HtmlDocument doc = new HtmlDocument();
        doc.LoadHtml(s);
        doc.Save(Console.Out);
    
        Console.WriteLine();
        Console.WriteLine();
    
        foreach (HtmlParseError err in doc.ParseErrors)
        {
            Console.WriteLine("Error");
            Console.WriteLine(" code=" + err.Code);
            Console.WriteLine(" reason=" + err.Reason);
            Console.WriteLine(" text=" + err.SourceText);
            Console.WriteLine(" line=" + err.Line);
            Console.WriteLine(" pos=" + err.StreamPosition);
            Console.WriteLine(" col=" + err.LinePosition);
        }
    

    It will display this (the corrected text first, and details about the error then):

    <span style="color: #0000FF;"></span>
    
    Error
     code=EndTagNotRequired
     reason=End tag </> is not required
     text=<
     line=1
     pos=30
     col=31
    

    So you can try to fix this error, as you have all required information (including line, column, and stream position) but the general process of fixing (not detecting) errors in HTML is very complex.

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

Sidebar

Related Questions

I have recently started experimenting with Django for some web applications in my spare
Hi I recently started experimenting with python currently reading Think like a computer scientist:
I have recently started experimenting with LLVM under MinGW. I have read the Kaleidoscope
I've recently started experimenting with PostSharp and I found a particularly helpful aspect to
Recently, I've started experimenting with Mercurial, due to the fact that it always attracted
Recently started with linq to sql and i am not sure what is the
I recently started experimenting with Python decorators (and higher-order functions) because it looked like
I recently started experimenting with CakePHP. I used this query in normal PHP and
Recently started with OpenGL, I have managed to draw a background image on screen
I have recently just started learning how to develop android applications. I am am

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.