Translator Framework issue

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()") // returns null
date : FW.Xpath("//div/").text() // returns AB

How can I fetch just 'B'?
  • edited August 12, 2012
    That's a tough construct to parse. You could fetch A and fetch AB, and then chop the length of A from the front of AB.
  • @fbennett Can you please give me some code? I can not run anything in FS.Scrapper()
  • I haven't used the framework yet, so I can't provide a worked example. But it can save to an item variable segment, so if the variable you're trying to fetch is "publisher", you should be able to do something like:

    item.publisher = (magic incantation for A)
    var tmp = item.publisher;
    item.publisher = (magic incantation for AB)
    item.publisher = item.publisher.slice(tmp.length);

    More or less.
  • @fbennett Thanks. My concern is Translator Framework.
    Without it we can easily use "//div/text()" xpath for fetching B
  • Again. you'll probably have better luck on zotero-dev.
  • I tried followings all failed:
    date : FW.Xpath("//div/text()") // returns null
    date : FW.Xpath("//div/").text() // returns AB
    use
    FW.Xpath("//div/text()").text()
    Xpath() returns a node, so you need to get the text() regardless of what you put in the xpath.
  • @aurimas I also tried it (FW.Xpath("//div/text()").text())
    it returns null
Sign In or Register to comment.