1

I would like to better understand the meaning and usefulness of . before /h3. I looked for a website with a tutorial, but I couldn't find one explaining its use.

//div[./h3/a[text()='Home']]
kjhughes
  • 106,133
  • 27
  • 181
  • 240
Digital Farmer
  • 1,705
  • 5
  • 17
  • 67

1 Answers1

1

The difference is that of relative vs absolute selection.

Disregarding the /a[text()='Home'] common to both cases:

  • Relative selection: //div[./h3] selects all div elements that have an h3 child element.
    Note that it can be simplified to //div[h3].
  • Absolute selection: //div[/h3] selects all div elements provided that the document root element is h3.

Absolute tests such as /h3 within a predicate ([/h3]) are relatively uncommon.

See also

kjhughes
  • 106,133
  • 27
  • 181
  • 240