In some search operations in calibre one can use an xpath expression to get the values for particular tags, i.e. the following expression:

//h:div[re:test(@class, "figbox", "i")]

selects the content of a "div" tag whose "class" attribute is set to "figbox", so in the following html line:

<div class="figbox">Volterra</div>

the preceding xpath expression returns the value "Volterra". This is useful to compile the ToC of a book and for other tasks.


Now, with the following processing-instructions

<?bag value="2" content="Volterra"?>
<?bag value="3" content="Ferrara"?>

which xpath expression can I use to obtain the value "Ferrara" but not "Volterra"?


With the calibre editor I've tried putting in a book the following line

<?bag value="3" content="Ferrara"?>

and testing the following expressions to add the word "Ferrara" in the ToC:


substring-before(substring-after(//processing-instruction('bag'), 'value="3" content="'), '"')

but in both cases I get only

"calibre, version 3.30.0
ERROR: No items found: No items were found that could be added to the Table of Contents.
  • Most of the posts here are read by fewer than 10 people. You're more likely to get an answer in the official Calibre forum. BTW, if you used heading tags, you could automatically generate TOCs. – user4665 Sep 1 '18 at 9:23
  • @NemoXXX I posted in Calibre forum but with no better fortune. Sadly I definitely need an help about processing instructions. – Reverendo Asperso Sep 1 '18 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.