web analytics

Learning XPath Expressions By Examples

Options
@2016-01-16 09:41:19

What is the title of chapter 2?

//chapter[2]/title
//chapter[position()=2]/title
//chapter[@id="2"]/title
//chapter[@id='2']/title

 

@2016-01-16 11:44:05

How much does this book cost?

concat(/book/price, " (", /book/price/@currency, ")")
concat(ceiling(/book/price), " (", /book/price/@currency, ")")
concat(floor(/book/price), " (", /book/price/@currency, ")")
concat(round(/book/price), " (", /book/price/@currency, ")")
concat(substring-before(/book/price, "."), " dollars and ", substring-after(/book/price,"."), " cents")

 

@2016-01-16 11:45:52

Given 15% discount, how much will this book cost?

/book/price * 0.85

 

@2016-01-16 13:24:05

Select all even-numbered chapters

/book/chapter[position() mod 2 = 0]

 

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com