Fuzi icon indicating copy to clipboard operation
Fuzi copied to clipboard

Is xpath lookup from root node, not from current node?

Open iDevPro opened this issue 5 years ago • 6 comments

Description:

  • Expected behaviour: XPath look from node not root.

  • Actual behaviour: XPath look from root not node.

For example, I looked for 20 nodes with a certain class. After, I iterate result for look inside for one item with selected class (I know there is one object with this class). I checked count, it returned 20 not 1.

Environment

  • Package Manager:

    • [ ] Carthage, version:
    • [ ] CocoaPods, version:
    • [*] Manually
  • Fuzi version: 1.0.1

  • Xcode version: 11.2

How to reproduce:

let nodes = root.xpath(searchForNodes)
print(nodes.count) // return 20, expected 20
nodes.forEach({
    let subNodes = $0.xpath(searchForOneSubNode)
    print(subNodes.count) // return 20, expected 1. repeated for all node
})

iDevPro avatar Nov 10 '19 15:11 iDevPro

Could you please provide repro code that can execute rather than pseudo-code? Thanks

cezheng avatar Nov 19 '19 00:11 cezheng

Also, please use the latest Fuzi version 3.1.1. Version 1.0.1 is a few years old already, I don't expect it to work with Xcode 11.

cezheng avatar Nov 19 '19 00:11 cezheng

Снимок экрана 2019-12-27 в 10 16 36

There is I found 20 books per page, enumerate it and parse book by book. When I tried to get the book author by the XPath template, I got an object with 20 subnodes.

P.s.: Also, I found a memory consumption problem but this is another story... (maybe that is Xcode instruments bug)

P.s.p.s.:

cat Fuzi.podspec 
Pod::Spec.new do |s|
  s.name         = "Fuzi"
  s.version      = "3.1.1"
  s.license      = "MIT"

git branch
* master

git pull
Already up to date.

iDevPro avatar Dec 27 '19 07:12 iDevPro

I mean would you mind providing executable source code that I can use run and debug rather than just a screenshot of a code snippet? I don't even know what XML you are parsing and what xpath query you used.

cezheng avatar Dec 28 '19 22:12 cezheng

I did send an email for you with link to example-project

iDevPro avatar Jan 12 '20 20:01 iDevPro

Снимок экрана 2020-04-06 в 12 25 55 Hello, did you try my code ?)

iDevPro avatar Apr 06 '20 09:04 iDevPro