-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Chained xpaths are searching from root level #237
Comments
To define a relative path you have to use dot-notation(.//). XCTAssertNil(doc.at_xpath("//head")?.at_xpath(".//h1")?.toHTML)
XCTAssertNil(doc.at_xpath("//head")?.at_xpath(".//body")?.toHTML)
XCTAssertNil(doc.at_xpath("//body")?.at_xpath(".//title")?.toHTML)
XCTAssertEqual(doc.at_xpath("//body/div[@id='2']")?.at_xpath(".//h1")?.text, "test header 2")
//only this assert is ok, passes:
XCTAssertEqual(doc.at_xpath("//body/div[@id='2']//h1")?.text, "test header 2") I understand this is confusing. I plan to change it so that it works even if dot notation is omitted in a future release. |
anivaros
added a commit
to anivaros/Kanna
that referenced
this issue
Apr 14, 2020
anivaros
added a commit
to anivaros/Kanna
that referenced
this issue
Apr 15, 2020
anivaros
added a commit
to anivaros/Kanna
that referenced
this issue
Apr 18, 2020
anivaros
added a commit
to anivaros/Kanna
that referenced
this issue
Apr 18, 2020
anivaros
added a commit
to anivaros/Kanna
that referenced
this issue
Apr 18, 2020
…node + added test to check that
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description:
All node xpaths are calling for root document level, not for node. For example, this test will fail.
Is it bug or feature?
I've started implementing fix of this problem I'm casting xmlNodePtr to xmlDocPtr and initing xmlXPathNewContext with this casted object and then all xpaths starting work properly.
The text was updated successfully, but these errors were encountered: