Consider Following markup:
<div>
<span>A</span>
B
</div>
I want fetch “B” using translator framework.
I tried followings all failed:
date : FW.Xpath("//div/text()") // date -> null
date : FW.Xpath("//div/").text() // date -> AB
How can I fetch just ‘B’?
Try:
Or:
The issue, discussed recently on the Zotero forum, is that the .text() call in Framework returns the first text node matched, so the first expression in your question gives the empty text node preceding the tag.
The right solution here will depend on what flexibility you want to have– if you need the next text node after the span, generally speaking, then you want the first option. If you want the last one before the end of the outer div, you want the second.
(For others interested in looking into this, this is using the Framework for Zotero site translators, one of the several ways to write site scrapers and more for the Zotero research management system.)