3

How to find the attribute is available or not in particular element?

1

2 Answers 2

4

Use XPath that will return your target attribute and convert the result to boolean :

boolean(//target_element/@target_attribute)

or similar approach but using exists() function :

exists(//target_element/@target_attribute)

Actually, the context isn't clearly stated in the question, for example, maybe the context element in your case is the target element already, so you don't need //target_element/ part.

0

Also, you can return all of the attribute names for the target element:

//target-element/(@*[1])

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.