89

What is the XPath expression for selecting all elements with attribute A?

const char* xpath = "//\*/\*[@A]"
ThomasRS
  • 8,215
  • 5
  • 33
  • 48
eugene
  • 39,839
  • 68
  • 255
  • 489
  • 1
    Not 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). – Mads Hansen Apr 11 '11 at 11:14

1 Answers1

212

This XPath selects all elements that have an A attribute:

//*[@A]
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147