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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:12:08+00:00 2026-05-17T06:12:08+00:00

My first post here – it’s a great site and I will certainly do

  • 0

My first post here – it’s a great site and I will certainly do my best to give back as much as I can.

I have seen different manifestations of this following question; however my attempts to resolve don’t appear to work.

Consider this simple tree:

<root>
    <div>
        <p>hello</p>
        <p>hello2</p>
        <p><span class="bad">hello3</span></p>
    </div>
</root>

I would like to come up with an XPath expression that will select all child nodes of “div”, except for elements that have their “class” attribute equal to “bad”.

Here is what I have tried:

/root/div/node()[not (@class='bad')]

… However this doesn’t seem to work.

What am I missing here?

Cheers,
Isaac

  • 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-17T06:12:08+00:00Added an answer on May 17, 2026 at 6:12 am

    When testing your XPath here with the provided XML document, the XPath seems to be indeed selecting all child nodes that do not have an attribute class="bad" – these are all the <p> elements in the document.

    You will note that the only child node that has such an attribute is the <span>, which indeed does not get selected.

    Are you expecting the p node surrounding your span not to be selected?

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

Sidebar

Related Questions

first post here, I come in peace :) I've searched but can't quite find
first post here at this great website! I would like to reduce the amount
My first post here – hoping you can help me with designing an algorithm
First post here... I normally develop using PHP and Symfony with Propel and ActionScript
First post here so sorry if I seem like a newb, I am trying
first post here, and probably an easy one. I've got the code from Processing's
First post here. Having a problem with NSNumber's floatValue method -- somehow, it returns
My first post here! Seems like this is the place to get wise ;)
My first post here, so i hope this is the right area. I am
My first post here. I want to make a horizontal menu with submenu's sliding

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.