[web] xpath syntax

Web 2018. 3. 29. 21:12

'/'

 - root (absolute path)

 - example: '/html'


'//'

 - everywhere

 - example: '//p'


'.//'

 - relative path

 - example: './/p'


'*'

 - every node

 - example: '//*'


'@attr'

 - attribute

 - example: '//@title', '//img/@src', '//a/@href'


'[1]'

 - index, from 1 to n (not 0)

 - example: '//p[12]'


'[@attr="str"]'

 - condition

 - example: '//img[@src="phone.jpg"]'


'text()'

 - text of tag

 - example: '//p/text()'




WRITTEN BY
hojongs
블로그 옮겼습니다 https://hojongs.github.io/