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
  • 98,039
  • 18
  • 159
  • 218
Digital Farmer
  • 675
  • 3
  • 11
  • 37

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
  • 98,039
  • 18
  • 159
  • 218