Fuzi
Fuzi copied to clipboard
Is xpath lookup from root node, not from current node?
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
})
Could you please provide repro code that can execute rather than pseudo-code? Thanks
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.

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.
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.
I did send an email for you with link to example-project
