web analytics

Learning XPath Expressions By Examples

Options
@2016-01-17 17:08:43

Select the chapter with a title named "XPath"

/book/chapter/title[text()="XPath"]/parent::*
/book/chapter/title[text()="XPath"]/..
/book/chapter/title[text()="XPath"]/parent::node()

 

@2016-01-17 17:11:20

Select the chapter and its ancestor with a chatper title named "XPath"

/book/chapter/title[text()="XPath"]/ancestor::*

 

 

@2016-01-17 17:17:34

Select all the chapters after the chapter with a title named "XPath"

/book/chapter/title[text()="XPath"]/../following-sibling::chapter

 

@2016-01-17 17:20:25

Select all the chapters before the chapter with a title named "XPath"

/book/chapter/title[text()="XPath"]/../preceding-sibling::chapter

 

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com