0

I'm trying to obtain the top-most nodes of a given name, i.e. that aren't nested within other nodes of that name.

I'm trying to do it with the following, which is not working:

$(xmldoc).find("idea:not(:parent > idea)")
4
  • I think you can use .children() instead of find(), I'm sure that only returns the top level of items. Something like $(xmldoc).children(".node_of_a_given_name");
    – Jeemusu
    Aug 2, 2012 at 1:10
  • It doesn't return the top-most items, it only searches the top level. This isn't suitable because the nodes I'm seeking can be nested anywhere deeply in the DOM structure. It's not the nodes at the top of the structure I'm seeking but the top-most nodes of that particular name.
    – Rob F
    Aug 2, 2012 at 1:24
  • 1
    Seems idea:not(idea idea) might be the answer...
    – Rob F
    Aug 2, 2012 at 1:28
  • so your xml is something like this? <idea a><idea></idea><idea></idea><idea></idea></idea> <idea b><idea></idea><idea></idea><idea></idea></idea> (where a and b are the nodes you want) Aug 2, 2012 at 1:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.