How to find the attribute is available or not in particular element?
Asked
Active
Viewed 236 times
2 Answers
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.

har07
- 88,338
- 12
- 84
- 137
0
Also, you can return all of the attribute names for the target element:
//target-element/(@*[1])

Kindle Q
- 944
- 2
- 19
- 28