Open carlows opened 3 years ago
thanks for report. it is a bug of position()
in logical
operation.
Maybe I can help debugging it and open a PR, do you have an idea of where to look in the code?
Sorry, it was not about position()
bug, I found if change expr to this list := htmlquery.Find(doc, "//div[position()=1 and @class=\"test\"]/a/@href")
can works. I guess build.processNode()
have some bug.
If you are interesting, you can start at func (l *logicalQuery) Evaluate(t iterator) interface{} {...}
to debug.
Hi there,
First of all, thank you for the packages, they're very useful 🚀
I've been having issues with the
position
function and I'm not sure if it's an issue with the htmlquery package or the xpath package, here's an example:I would expect this to filter all the nodes that have the class
test
and have a position == 1, so only the first<a />
element. But instead, I get all the nodes. If I tryposition()=2
I get nothing back.If I instead use this xpath, it gives me the correct element:
If I try this on the browser it works, so I'm not sure if it is expected that it works this way here 🤔.
What could be the problem? Thank you again!