Using XPath with bookmap metadata

DmitryS
Posts: 21
Joined: Wed Nov 27, 2019 11:03 am

Using XPath with bookmap metadata

Post by DmitryS » Mon Dec 23, 2019 2:29 pm

Hi!
Please help me to return the value of bookmeta/bookrights/copyrlast/year.
Expression

Code: Select all

//*[contains(@class, "bookmap/year")]/text() 
returns two values, from <copyrfirst> and <copyrlast>.

Sincerely,
Dmitry

alex_jitianu
Posts: 733
Joined: Wed Nov 16, 2005 11:11 am

Re: Using XPath with bookmap metadata

Post by alex_jitianu » Mon Dec 30, 2019 11:17 am

Hi Dmitry,

That's because both copyrlast and copyrfirst have a year element in them, and your XPath takes all the year elements from anywhere in the document. Just restrict the expression to the year from withing copyrlast, like this:

Code: Select all

//*[contains(@class, "bookmap/copyrlast")]/*[contains(@class, "bookmap/year")]/text() 
Best regards,
Alex

DmitryS
Posts: 21
Joined: Wed Nov 27, 2019 11:03 am

Re: Using XPath with bookmap metadata

Post by DmitryS » Tue Dec 31, 2019 10:08 am

Thank you, Alex!

Sincerely,
Dmitry

Post Reply