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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:00:49+00:00 2026-06-04T18:00:49+00:00

I have a parent element (font) and I would like to select all the

  • 0

I have a parent element (font) and I would like to select all the child elements (direct descendants) that are either text() or span elements. How would I construct such an xpath?

  • 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-04T18:00:50+00:00Added an answer on June 4, 2026 at 6:00 pm

    If the current node is the font element, then something like this:

    text()|span
    

    otherwise you have to always combine with | the two complete XPath – the one for text and the one for span, e.g.:

    font/text()|font/span
    

    if the current node is just above font – or

    //a[text()='View Larger Map']/../../../../div[contains(@class, 'paragraph')][3]/font/span|//a[text()='View Larger Map']/../../../../div[contains(@class, 'paragraph')][3]/font/text()
    

    if starting from the root with some complex selection criteria.

    If you have complex paths like the last one probably it is better to store a partial one in a variable – e.g. inside an XSLT:

    <xsl:variable name="font" select="//a[text()='View Larger Map']/../../../../div[contains(@class, 'paragraph')][3]/font"/>
    
    . . . 
    
    <xsl:for-each select="$font/span|$font/text()">
      . . . 
    </xsl:for-each>
    

    Another possibility is to do something like this:

    //a[text()='View Larger Map']/../../../../div[contains(@class, 'paragraph')][3]/font/node()[name()='span' or name()='']
    

    that works because name() returns an empty string for text() nodes – but I am not 100% sure that it works that way for all XPath processors, and it could match by mistake comment nodes.

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

Sidebar

Related Questions

I have a parent element that has dynamic text in it that needs to
I have a parent element with some child elements. The child elements have a
I have used font-size: 0; on the parent element and that's how I got
I have a parent element with a real lot of child elements (1000s). I
let say I have a parent element which has so many nested child elements
I know I can have 1 parent element and 1 child element in my
I have have a 2 div element. One is child and one is parent
I have a parent div that has a class style with font-size:11px. I want
I have tspan element with some text in it. I specified some font-size for
I have a bunch of span elements in random positions enclosed inside a parent

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.