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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:50:09+00:00 2026-05-17T15:50:09+00:00

Problem: Extract all html between two headers including the headers html. The header text

  • 0

Problem:
Extract all html between two headers including the headers html. The header text is known, but not the formatting, tag name, etc. They are not within the same parent and might (well, almost for sure) have sub children within it’s own children).

To clarify: headers could be inside a <h1> or <div> or any other tag. They may also be surrounded by <b>, <i>, <font> or more <div> tags. The key is: the only text within the element is the header text.

The tools I have available are: C# 3.0 utilizing a WebBrowser control, or Jquery/Js.

I’ve taken the Jquery route, traversing the DOM, but I’ve ran into the issue of children and adding them appropriately. Here is the code so far:

function getAllBetween(firstEl,lastEl) {
    var collection = new Array(); // Collection of Elements
    var fefound =false;
    $('body').find('*').each(function(){
        var curEl = $(this);
        if($(curEl).text() == firstEl) 
            fefound=true;
        if($(curEl).text() == lastEl) 
            return false;

        // need something to add children children
        // otherwise we get <table></table><tbody></tbody><tr></tr> etc
        if (fefound)
            collection.push(curEl);
    });
    var div = document.createElement("DIV");
    for (var i=0,len=collection.length;i<len;i++){
        $(div).append(collection[i]);
    }
    return($(div).html());
}

Should I be continueing down this road? With some sort of recursive function checking/handling children, or would a whole new approach be better suited?

For the sake of testing, here is some sample markup:

<body>
<div>
<div>Start</div>
<table><tbody><tr><td>Oops</td></tr></tbody></table>
</div>
<div>
<div>End</div>
</div>
</body>

Any suggestions or thoughts are greatly appreciated!

  • 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-17T15:50:09+00:00Added an answer on May 17, 2026 at 3:50 pm

    My thought is a regex, something along the lines of

    .*<(?<tag>.+)>Start</\1>(?<found_data>.+)<\1>End</\1>.*
    

    should get you everything between the Start and end div tags.

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

Sidebar

Related Questions

Problem: I have two spreadsheets that each serve different purposes but contain one particular
I'm creating a html-layout based on an existing layout. I want to extract all
Trying to parse an HTML document and extract some elements (any links to text
I'm trying to extract all words from a string into an array, but i
This is the simplified version of my problem: I'm trying to extract all letters
My problem is :: From a string like /usr/folder1/folder2/filename.ext I have to extract out
Problem is described and demonstrated on the following links: Paul Stovell WPF: Blurry Text
This is a fairly simple problem, I'm just not sure exactly how to approach
Given an HTML page I would like to get all the 'x' files that
I want to extract all words enclosed in curly braces, so I have an

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.