-1

everyone.

I have an HTML document that contains a very-nested element with a unique ID.

Can XPath find this element? I want to print its inner text.

If not, what do I have to specify? Location in document, tag, etc.?

I've tried to build some queries, but they don't work. I'm not 100% sure what I'm doing.

I'm a bit rusty with XPath, so explanations on how it works would be useful.

Thanks a lot in advance, Gal.

3

1 Answer 1

1

"Can XPath find this element?"

Yes it can. Without further details on the context, We can only suggest something like this :

//*[@id='your_unique_id_value_here']

The above XPath means, find all elements (should be only one anyway since id is unique as you described), whatever its name, where id attribute value equals "your_unique_id_value_here".

More introductory explanations on XPath : https://en.wikipedia.org/wiki/XPath

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.