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

  • Home
  • SEARCH
  • 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 9196027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:45:35+00:00 2026-06-17T21:45:35+00:00

For example: <a> <b> <c1>c1 text</b1> <c2 c2attr=10>c2 text</b2> <c3>c3 text</b3> </b> <b> <c1>c1

  • 0

For example:

<a>
  <b>
    <c1>c1 text</b1>
    <c2 c2attr="10">c2 text</b2>
    <c3>c3 text</b3>
  </b>
  <b>
    <c1>c1 text</b1>
    <c2 c2attr="5">c2 text</b2>
    <c3>c3 text</b3>
  </b>
</a>

I want to select the <b> element which has a <c2> child with the maximum c2attr attribute; in this example, the first one (10 > 5).

I have tried

/a/b[not(c2@c2attr <= preceding-sibling::c2@c2attr) and not(c2@c2attr <=following-sibling::c2@c2attr)]

But PHP says that it’s invalid…

  • 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-17T21:45:37+00:00Added an answer on June 17, 2026 at 9:45 pm

    You’re missing slashes before the @ signs, and you need to look for preceding-sibling elements named b, not c2:

    /a/b[not(c2/@c2attr <= preceding-sibling::b/c2/@c2attr) and not(c2/@c2attr <=following-sibling::b/c2/@c2attr)]
    

    However this kind of check will be quadratic in the number of b elements, as it’s comparing every b with every other b. It would be more efficient to simply extract all the b elements, then iterate over them (once) using PHP code, keeping track of the highest c2attr value you’ve seen so far and which b that belongs to. This would be linear rather than quadratic.

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

Sidebar

Related Questions

I have a string which looks like: <html><head><title>example</title></head><body>some example text</body></html> I get this string
I have a RichTextBox with -by example- this text: This is my Text Now
I have a text file which has more than 200 lines in it, and
I want to convert text which user is copying from my textbox. For example:
Example Text: This will be stored in the $_POST['x'] variable This is sentence one.
I have a string for example like :)text :)text:) :-) word :-( i need
I have to develop a simple parser, to read block of text for example:
The fields in my form have a label, some help text, some example text,
Hello I have a text file with three lines. every line has a float
Here an example text Label: Some-text-here How can i have it so when i

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.