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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:11:03+00:00 2026-05-30T21:11:03+00:00

How do I get the first element that has an inner text (plain text,

  • 0

How do I get the first element that has an inner text (plain text, discarding other children) of 200 or more characters in length?

I’m trying to create an HTML parser like Embed.ly and I’ve set up a system of fallbacks where I first check for og:description, then I would search for this occurrence and only then for the description meta tag.

This is because most sites that even include meta description describe their site in that tag, instead of the contents of the current page.

Example:

<html>
    <body>
        <div>some characters
            <p>200 characters <span>some more stuff</span></p>
        </div>
    </body>
</html>

What selector could I use to get the 200 characters portion of that HTML fragment? I don’t want the some more stuff either, I don’t care what element it is (except for <script> or <style>), as long as it’s the first plain text to contain at least 200 characters.

What should the XPath query look like?

  • 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-30T21:11:04+00:00Added an answer on May 30, 2026 at 9:11 pm

    Use:

    (//*[not(self::script or self::style)]/text()[string-length() > 200])[1]
    

    Note: In case the document is an XHTML document (and that means all elements are in the xhrml namespace), the above expression should be specified as:

    (//*[not(self::x:script or self::x:style)]/text()[string-length() > 200])[1]
    

    where the prefix "x:" must be bound to the XHTML namespace — "http://www.w3.org/1999/xhtml" (or as many XPath APIs call this — the namespace must be “Registered” with this prefix)

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

Sidebar

Related Questions

How can I get the id of an element that has been clicked, if
How can I ignore first element and get rest of the elements? <ul> <li><a
Normally, we get first value that way: $(#color option:first).val() But I need something like
I am trying to get the first word in the line that matches the
Is it possible to get the first line of text from a UITextView. I
I have an ASP.NET GridView that has four columns. The first three are typical
I have a BYTE data[3]. The first element, data[0] has to be a BYTE
How can I determine the explicit width of a HTML element that has width
I want to get one element that is already on the page in the
I want to get the first parent which has a specific class prefix, suppose:

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.