How to select all elements with a specific attribute? with TinyXPath
62,969
This XPath selects all elements that have an A attribute:
//*[@A]
Related videos on Youtube
Author by
eugene
I am working on littlehome.kr If you'd like to give a hand, please join us.
Updated on November 20, 2020Comments
-
eugene over 3 years
What is the XPath expression for selecting all elements with attribute A?
const char* xpath = "//\*/\*[@A]"
-
Mads Hansen about 13 yearsNot sure about the need to escape the
*
, but your current XPath is selecting all elements that have an@A
and are children of an element, so it would match for most elements but you would miss the document element if it had an A attribute(since it won't have a parent element).
-