How to select all elements with a specific attribute? with TinyXPath

62,969

This XPath selects all elements that have an A attribute:

//*[@A]
Share:
62,969

Related videos on Youtube

eugene
Author by

eugene

I am working on littlehome.kr If you'd like to give a hand, please join us.

Updated on November 20, 2020

Comments

  • eugene
    eugene over 3 years

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

    const char* xpath = "//\*/\*[@A]"
    
    • Mads Hansen
      Mads Hansen about 13 years
      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).