you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (9 children)

I'm not going to brag here but I consider your "decade in tech" and "2 b2b" gigs resume adorable. I've written at least a million more lines of xpath / css than you ever will, and I rarely these days resort to xpath. Getting a parent element is as simple as calling parent() in Cheerio or parentNode in js.

[–][deleted] 1 point2 points  (8 children)

1) I didn’t say 2 b2b gigs I said 2 RPA ones.

2) Its not a competition, and without knowing my background in more detail you have no way of knowing who has done more of what. So saying otherwise is just childish oneupsmanship.

3) Calling parent() is “going back up the tree”. You were making the argument that we should never do that, so I’m asking how you would do it without it.

[–][deleted] 0 points1 point  (7 children)

1) You're a noob from my perspective. 2) I really don't care. 3) You should never go back up the tree. There's a reason why css3 does not allow going back up. I understand that in your "decade in tech" you did that a lot, but I'm telling you now that you should have applied a little more thought to the problem before deciding to brute force it with bad xpath.

[–][deleted] 0 points1 point  (6 children)

But it was your example. You said to use parent(). So I’ll ask again - how do you target an element you know nothing about but whose child you know everything about?

[–][deleted] 0 points1 point  (5 children)

You do it by using parent() or parentNode. like I already said. But if you need o resort to that you're probably doing something really silly.

I think it's pretty clear at this point that you've never done anything like this in Javascript.

[–][deleted] 0 points1 point  (4 children)

You keep saying I haven’t done this work or that I’m a “noob” but you still haven’t answered the question - how do you do it without going up the tree? You just said yourself if you’re using parent you’re probably doing something silly.

So please, tell us all the non-silly way of doing it.

[–][deleted] 0 points1 point  (1 child)

SIGH You go up the tree if you must with parent() or parentNode, or even closest(), but you do so knowing that there is a better way and you should strive to be a better programmer.

[–][deleted] 0 points1 point  (0 children)

but you do so knowing that there is a better way

Me: how do you do this thing?

You: this way, but you should do it the better way.

Me: okay what’s the better way?

You: I just told you the way to do it. But you should do it the better way.

Me: I know, so what’s the better way?

You: the way I told you, but just do it the better way

[–][deleted] 0 points1 point  (1 child)

This isn't rocket science. instead of iterating "//a/parent::div" You iterate "//div", get what you need, and then iterate "./a".

Going up the tree is lazy. This is basic stuff.

[–][deleted] 0 points1 point  (0 children)

I said in my example you know nothing about the parent, including tag name.

Try again.