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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:09:10+00:00 2026-06-08T10:09:10+00:00

I’m using Webharvest to retrieve data from websites. It converts the html pages to

  • 0

I’m using Webharvest to retrieve data from websites. It converts the html pages to xml documents before getting for me the wanted data based on the xPath provided.

Now I’m working on a page like this: pastebin Where I showed the blocks I’d like to get. Each block should be returned as a single unit.

the xPath the first element of the block is: //div[@id="layer22"]/b/span[@style="background-color: #FFFF99"]
I tested it and it gives all “bloc start” elements.

the xPath of the last element of the block is: //div[@id="layer22"]/a[contains(.,"Join")]
I tested it and it gives all the “bloc end” elements.

The xPath should return a set of blocks as:

(xPath)[1] = block 1

(xPath)[2] = block 2

….

Thank you 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-06-08T10:09:12+00:00Added an answer on June 8, 2026 at 10:09 am

    Use (for the first wanted result):

      ($first)[1] | ($last)[1]
    
    |
    
      ($first)[1]/following::node()
           [count(.|($last)[1]/preceding::node()) = count(($last)[1]/preceding::node())]
    

    where you need to substitute $first with:

    //div[@id="layer22"]/b/span[@style="background-color: #FFFF99"]
    

    and substitute $last with:

    //div[@id="layer22"]/a[contains(.,"Join")] 
    

    To get the k-th result, substitute in the final expression ($first)[1] with ($first)[{k}] and ($last)[1] with ($last)[{k}], where {k} should be replaced by the number k.

    This technique follows directly from the well-known Kayessian formula for set intersection in XPath 1.0:

    $ns1[count(.|$ns2) = count($ns2)]
    

    which selects the intersection of the two node-sets $ns1 and $ns2 .

    Here is XSLT verification with a simple example:

    <nums>
      <num>01</num>
      <num>02</num>
      <num>03</num>
      <num>04</num>
      <num>05</num>
      <num>06</num>
      <num>07</num>
      <num>03</num>
      <num>07</num>
      <num>10</num>
    </nums>
    

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:variable name="v1" select=
      "(//num[. = 3])[1]/following-sibling::*"/>
     <xsl:variable name="v2" select=
      "(//num[. = 7])[1]/preceding-sibling::*"/>
    
     <xsl:template match="/">
      <xsl:copy-of select=
      "$v1[count(.|$v2) = count($v2)]"/>
     </xsl:template>
    </xsl:stylesheet>
    

    applies the XPath expression and the selected nodes are copied to the output:

    <num>04</num>
    <num>05</num>
    <num>06</num>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the

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.