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

  • Home
  • SEARCH
  • 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 130545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:57:53+00:00 2026-05-11T05:57:53+00:00

When I realized I needed to create an index for approximately 50 XHTML pages,

  • 0

When I realized I needed to create an index for approximately 50 XHTML pages, which may be added/deleted/renamed/moved in the future, I thought ‘No problem — I’ll write a quick index generator using LINQ to XML, since XHTML definitely counts as XML’.

Of course, as soon as I tried running it, I found out about the fact that XLINQ chokes on XHTML entities like  . I got around it by using the following algorithm:

  1. Read XHTML file into string.
  2. Use regex search and replace on that string to add a section into the DOCTYPE that defines all relevant entities (because I only care about the ‘title’ attribute in the files I read and my output file does not use any entities right now, it just sets them all to blank, but I may add the actual values later).
  3. Parses the result into an XDocument.

To save a file, I do the opposite:

  1. Save XDocument to a string.
  2. Strip out the entity definitions.
  3. Save to file.

My question is, are there any libraries (especially built-in .Net ones) I can use that will read XHTML files into XDocuments? The code I wrote has accomplished its purpose (to generate the current index and to test the rest of the generator program), and I would really prefer not to spend time testing it if someone else already wrote and tested the same thing.

Thank y’all so much for your time,
Ria.

Edit: Thank you so much; this works! I still have to do a little string processing when I save the XHTML (guess the library was not really made for that:)) and I had to fiddle with the source of the Agility Pack slightly to get it to stop indiscriminately sticking a CDATA section around the insides of every style attribute (even when there was already one present), but that’s the point of Open Source, right?

  • 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. 2026-05-11T05:57:54+00:00Added an answer on May 11, 2026 at 5:57 am

    This might be helpful: LINQ & Lambda, Part 3: Html Agility Pack to LINQ to XML Converter

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

Sidebar

Related Questions

working on xcode I realized that if I create a non-void method, I call
In some projects I see that a dummy record is needed to create in
My script creates a directory. Before I realized that I needed to chown() the
I realized this issue when trying to sum upvotes AND downvotes because the value
I realized that I can have problems with single quotes in php arrays: <?php
I realized today that I have blindly just followed this requirement for years without
I realized that appears this interface in .NET Framework 4.5 I was looking first
I realized that ShowHeaderWhenEmpty only works in PostBacks. Is there any way to make
I realized that my application doesn't show up in searches on Google Play if
I just realized that in different Activities, I use different SharedPreferences. For example, I

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.