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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:30:19+00:00 2026-05-28T07:30:19+00:00

Question 1 Here is the HTML code. <div class=preferredContact paragraph>ph:<span preferredcontact=40>(02) 9540 9959</span></div> I

  • 0

Question 1

Here is the HTML code.

<div class="preferredContact paragraph">ph:<span preferredcontact="40">(02) 9540 9959</span></div> 

I am trying to extract that phone number using xpath.

I have tried

data['phone'] = c.xpath('.//span[@preferredContact="40"]/text()')

and

data['phone'] = c.xpath('.//span[contains(@preferredContact,"40")]/text()')

Both of them return only null. Can someone show me the code to extract that phone number, please?

Question 2

HTML code is

<a rel="nofollow" title="View website for Ruth Newman Architect (in new window)" target="_blank" name="listing_website" id="websiteLink40" alreadysentorpevent="false" class="links ext-no-tooltip orpDuplicateEvent" href="/app/redirect?headingCode=27898&amp;productId=473639214&amp;productVersion=1&amp;listingUrl=%2Fnsw%2Fgymea-bay%2Fruth-newman-architect-12781682-listing.html&amp;webSite=http%3A%2F%2Fwww.ruthnewman.com.au&amp;pt=w&amp;context=businessTypeSearch&amp;referredBy=YOL&amp;eventType=websiteReferral">www.ruthnewman.com.au
</a>

I want to get the link which is located next to the string webSite=http%3A%2F%2F. This string is in the href attribute’s value. So, in the above example, I want http://www.ruthnewman.com.au. I do not know how to get that using Xpath.

Can someone help out please?

  • 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-28T07:30:20+00:00Added an answer on May 28, 2026 at 7:30 am

    Attributes are case-sensitive. For the first question use (no caps):

    .//span[@preferredcontact='40']/text()
    

    For the second question use:

    substring-before(substring-after(
        .//a[contains(@href, 'webSite=')]/@href, 'webSite=http%3A%2F%2F'), '&')
    

    This first selects everything after 'webSite=http%3A%2F%2F' in the attribute, then, using that as the input to substring-before, extracts everything before the first &, which should contain the target string.

    Note that in your given examples the descendant-or-self (//) axis is not really needed. Try to avoid it whenever possible. The flexibility gained comes at the cost of precision and efficiency.

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

Sidebar

Related Questions

Okay, redoing the question to a much simpler one. Here's my HTML code. <p>
first question here. I'm developing a program in C# (.NET 3.5) that displays files
C# question here.. I have a UTF-8 string that is being interpreted by a
First question here: it is a very short yet fundamental thing in Java that
I've been trying to implement the jquery validator that is the suggested answer here:
I have created a image div in html and below is the code <div
As I said in another question in here, I'm creating a login class, but
I am trying to retrieve the position of an HTML element inside a paragraph.
I have a question about Ajax form submit. Here is the code: Controller [HttpPost,
It is a basic HTML question. I have some div tags, which have some

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.