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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:40:58+00:00 2026-05-19T09:40:58+00:00

I am trying to find a way to search for a string within nodes,

  • 0

I am trying to find a way to search for a string within nodes, but excluding ythe content of some subelements of those nodes. Plain and simple, I want to search for a string in paragraphs of a text, excluding the footnotes which are children elements of the paragraphs.

For example,

My document being:

<document>
   <p n="1">My text starts here/</p>
   <p n="2">Then it goes on there<footnote>It's not a very long text!</footnote></p>
</document>

When I’m searching for “text”, I would like the Xpath / XQuery to retrieve the first p element, but not the second one (where “text” is contained only in the footnote subelement).

I have tried the contains() function, but it retrieves both p elements.

Any help would be much 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-19T09:40:59+00:00Added an answer on May 19, 2026 at 9:40 am

    I want to search for a string in
    paragraphs of a text, excluding the
    footnotes which are children elements
    of the paragraphs

    An XPath 1.0 – only solution:

    Use:

    //p//text()[not(ancestor::footnote) and contains(.,'text')]
    

    Against the following XML document (obtained from yours but added p s within a footnote to make this more interesting):

    <document>
        <p n="1">My text starts here/</p>
        <p n="2">Then it goes on there
            <footnote>It's not a very long text!
               <p>text</p>
            </footnote>
        </p>
    </document>
    

    this XPath expression selects exactly the wanted text node:

    My text starts here/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find a way to automate some exception logging code to add
I am trying to (programatically) find references to a specific string i.e. 'LOCK_ID' within
I'm trying to find a way to list the (static) dependency requirements of a
I'm trying to find a way to validate a large XML file against an
I'm trying to find a way to fake the result of a method called
I'm trying to find a way to invoke the Ctrl+Alt+Delete dialog on a Windows
I am trying to find a way to determine at run-time how much memory
I'm trying to find a way to "pretty print" a JavaScript data structure in
I'm trying to find a way to get the execution time of a section
I'm trying to find a way to force Windows to reboot, and I am

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.