Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks
iDevPro opened this issue Nov 10, 2019 · 6 comments
Open
2 tasks

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

iDevPro opened this issue Nov 10, 2019 · 6 comments

Comments

@iDevPro
Copy link

iDevPro commented Nov 10, 2019

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
})
@cezheng
Copy link
Owner

cezheng commented Nov 19, 2019

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

@cezheng
Copy link
Owner

cezheng commented Nov 19, 2019

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.

@iDevPro
Copy link
Author

iDevPro commented Dec 27, 2019

Снимок экрана 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.

@cezheng
Copy link
Owner

cezheng commented Dec 28, 2019

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.

@iDevPro
Copy link
Author

iDevPro commented Jan 12, 2020

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

@iDevPro
Copy link
Author

iDevPro commented Apr 6, 2020

Снимок экрана 2020-04-06 в 12 25 55

Hello, did you try my code ?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants